1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class SignOrCreationError extends CommonBase {
16 private SignOrCreationError(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.SignOrCreationError_free(ptr); }
22 static SignOrCreationError constr_from_ptr(long ptr) {
23 bindings.LDKSignOrCreationError raw_val = bindings.LDKSignOrCreationError_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKSignOrCreationError.SignError.class) {
25 return new SignError(ptr, (bindings.LDKSignOrCreationError.SignError)raw_val);
27 if (raw_val.getClass() == bindings.LDKSignOrCreationError.CreationError.class) {
28 return new CreationError(ptr, (bindings.LDKSignOrCreationError.CreationError)raw_val);
30 assert false; return null; // Unreachable without extending the (internal) bindings interface
33 public final static class SignError extends SignOrCreationError {
34 private SignError(long ptr, bindings.LDKSignOrCreationError.SignError obj) {
38 public final static class CreationError extends SignOrCreationError {
39 public final org.ldk.enums.CreationError creation_error;
40 private CreationError(long ptr, bindings.LDKSignOrCreationError.CreationError obj) {
42 this.creation_error = obj.creation_error;
46 * Creates a copy of the SignOrCreationError
48 public SignOrCreationError clone() {
49 long ret = bindings.SignOrCreationError_clone(this.ptr);
50 if (ret < 1024) { return null; }
51 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
52 ret_hu_conv.ptrs_to.add(this);
57 * Utility method to constructs a new SignError-variant SignOrCreationError
59 public static SignOrCreationError sign_error() {
60 long ret = bindings.SignOrCreationError_sign_error();
61 if (ret < 1024) { return null; }
62 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
63 ret_hu_conv.ptrs_to.add(ret_hu_conv);
68 * Utility method to constructs a new CreationError-variant SignOrCreationError
70 public static SignOrCreationError creation_error(org.ldk.enums.CreationError a) {
71 long ret = bindings.SignOrCreationError_creation_error(a);
72 if (ret < 1024) { return null; }
73 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
74 ret_hu_conv.ptrs_to.add(ret_hu_conv);
79 * Checks if two SignOrCreationErrors contain equal inner contents.
80 * This ignores pointers and is_owned flags and looks at the values in fields.
82 public boolean eq(SignOrCreationError b) {
83 boolean ret = bindings.SignOrCreationError_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
89 * Get the string representation of a SignOrCreationError object
91 public String to_str() {
92 String ret = bindings.SignOrCreationError_to_str(this.ptr);