Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / SignOrCreationError.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
12  * may occur.
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.SignOrCreationError_free(ptr); }
21         }
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);
26                 }
27                 if (raw_val.getClass() == bindings.LDKSignOrCreationError.CreationError.class) {
28                         return new CreationError(ptr, (bindings.LDKSignOrCreationError.CreationError)raw_val);
29                 }
30                 assert false; return null; // Unreachable without extending the (internal) bindings interface
31         }
32
33         public final static class SignError extends SignOrCreationError {
34                 private SignError(long ptr, bindings.LDKSignOrCreationError.SignError obj) {
35                         super(null, ptr);
36                 }
37         }
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) {
41                         super(null, ptr);
42                         this.creation_error = obj.creation_error;
43                 }
44         }
45         /**
46          * Creates a copy of the SignOrCreationError
47          */
48         public SignOrCreationError clone() {
49                 long ret = bindings.SignOrCreationError_clone(this.ptr);
50                 if (ret >= 0 && ret < 1024) { return null; }
51                 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
52                 ret_hu_conv.ptrs_to.add(this);
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Utility method to constructs a new SignError-variant SignOrCreationError
58          */
59         public static SignOrCreationError sign_error() {
60                 long ret = bindings.SignOrCreationError_sign_error();
61                 if (ret >= 0 && ret < 1024) { return null; }
62                 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
63                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
64                 return ret_hu_conv;
65         }
66
67         /**
68          * Utility method to constructs a new CreationError-variant SignOrCreationError
69          */
70         public static SignOrCreationError creation_error(org.ldk.enums.CreationError a) {
71                 long ret = bindings.SignOrCreationError_creation_error(a);
72                 if (ret >= 0 && ret < 1024) { return null; }
73                 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
74                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Checks if two SignOrCreationErrors contain equal inner contents.
80          * This ignores pointers and is_owned flags and looks at the values in fields.
81          */
82         public boolean eq(SignOrCreationError b) {
83                 boolean ret = bindings.SignOrCreationError_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
84                 return ret;
85         }
86
87         /**
88          * Get the string representation of a SignOrCreationError object
89          */
90         public String to_str() {
91                 String ret = bindings.SignOrCreationError_to_str(this.ptr);
92                 return ret;
93         }
94
95 }