1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Represents an error returned from the bech32 library during validation of some bech32 data
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Bech32Error extends CommonBase {
16 private Bech32Error(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Bech32Error_free(ptr); }
22 static Bech32Error constr_from_ptr(long ptr) {
23 bindings.LDKBech32Error raw_val = bindings.LDKBech32Error_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKBech32Error.MissingSeparator.class) {
25 return new MissingSeparator(ptr, (bindings.LDKBech32Error.MissingSeparator)raw_val);
27 if (raw_val.getClass() == bindings.LDKBech32Error.InvalidChecksum.class) {
28 return new InvalidChecksum(ptr, (bindings.LDKBech32Error.InvalidChecksum)raw_val);
30 if (raw_val.getClass() == bindings.LDKBech32Error.InvalidLength.class) {
31 return new InvalidLength(ptr, (bindings.LDKBech32Error.InvalidLength)raw_val);
33 if (raw_val.getClass() == bindings.LDKBech32Error.InvalidChar.class) {
34 return new InvalidChar(ptr, (bindings.LDKBech32Error.InvalidChar)raw_val);
36 if (raw_val.getClass() == bindings.LDKBech32Error.InvalidData.class) {
37 return new InvalidData(ptr, (bindings.LDKBech32Error.InvalidData)raw_val);
39 if (raw_val.getClass() == bindings.LDKBech32Error.InvalidPadding.class) {
40 return new InvalidPadding(ptr, (bindings.LDKBech32Error.InvalidPadding)raw_val);
42 if (raw_val.getClass() == bindings.LDKBech32Error.MixedCase.class) {
43 return new MixedCase(ptr, (bindings.LDKBech32Error.MixedCase)raw_val);
45 assert false; return null; // Unreachable without extending the (internal) bindings interface
49 * String does not contain the separator character
51 public final static class MissingSeparator extends Bech32Error {
52 private MissingSeparator(long ptr, bindings.LDKBech32Error.MissingSeparator obj) {
57 * The checksum does not match the rest of the data
59 public final static class InvalidChecksum extends Bech32Error {
60 private InvalidChecksum(long ptr, bindings.LDKBech32Error.InvalidChecksum obj) {
65 * The data or human-readable part is too long or too short
67 public final static class InvalidLength extends Bech32Error {
68 private InvalidLength(long ptr, bindings.LDKBech32Error.InvalidLength obj) {
73 * Some part of the string contains an invalid character
75 public final static class InvalidChar extends Bech32Error {
76 public final int invalid_char;
77 private InvalidChar(long ptr, bindings.LDKBech32Error.InvalidChar obj) {
79 this.invalid_char = obj.invalid_char;
83 * Some part of the data has an invalid value
85 public final static class InvalidData extends Bech32Error {
86 public final byte invalid_data;
87 private InvalidData(long ptr, bindings.LDKBech32Error.InvalidData obj) {
89 this.invalid_data = obj.invalid_data;
93 * The bit conversion failed due to a padding issue
95 public final static class InvalidPadding extends Bech32Error {
96 private InvalidPadding(long ptr, bindings.LDKBech32Error.InvalidPadding obj) {
101 * The whole string must be of one case
103 public final static class MixedCase extends Bech32Error {
104 private MixedCase(long ptr, bindings.LDKBech32Error.MixedCase obj) {
109 long ret = bindings.Bech32Error_clone_ptr(this.ptr);
110 Reference.reachabilityFence(this);
115 * Creates a new Bech32Error which has the same data as `orig`
117 public Bech32Error clone() {
118 long ret = bindings.Bech32Error_clone(this.ptr);
119 Reference.reachabilityFence(this);
120 if (ret >= 0 && ret <= 4096) { return null; }
121 org.ldk.structs.Bech32Error ret_hu_conv = org.ldk.structs.Bech32Error.constr_from_ptr(ret);
122 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };