[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / InvoiceError.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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An error in response to an [`InvoiceRequest`] or an [`Bolt12Invoice`].
13  * 
14  * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
15  * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class InvoiceError extends CommonBase {
19         InvoiceError(Object _dummy, long ptr) { super(ptr); }
20         @Override @SuppressWarnings("deprecation")
21         protected void finalize() throws Throwable {
22                 super.finalize();
23                 if (ptr != 0) { bindings.InvoiceError_free(ptr); }
24         }
25
26         /**
27          * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error.
28          * 
29          * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
30          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
31          * 
32          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
33          */
34         @Nullable
35         public ErroneousField get_erroneous_field() {
36                 long ret = bindings.InvoiceError_get_erroneous_field(this.ptr);
37                 Reference.reachabilityFence(this);
38                 if (ret >= 0 && ret <= 4096) { return null; }
39                 org.ldk.structs.ErroneousField ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErroneousField(null, ret); }
40                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
41                 return ret_hu_conv;
42         }
43
44         /**
45          * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error.
46          * 
47          * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
48          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
49          * 
50          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
51          */
52         public void set_erroneous_field(@Nullable org.ldk.structs.ErroneousField val) {
53                 bindings.InvoiceError_set_erroneous_field(this.ptr, val == null ? 0 : val.ptr);
54                 Reference.reachabilityFence(this);
55                 Reference.reachabilityFence(val);
56                 if (this != null) { this.ptrs_to.add(val); };
57         }
58
59         /**
60          * An explanation of the error.
61          */
62         public UntrustedString get_message() {
63                 long ret = bindings.InvoiceError_get_message(this.ptr);
64                 Reference.reachabilityFence(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
68                 return ret_hu_conv;
69         }
70
71         /**
72          * An explanation of the error.
73          */
74         public void set_message(org.ldk.structs.UntrustedString val) {
75                 bindings.InvoiceError_set_message(this.ptr, val == null ? 0 : val.ptr);
76                 Reference.reachabilityFence(this);
77                 Reference.reachabilityFence(val);
78                 if (this != null) { this.ptrs_to.add(val); };
79         }
80
81         /**
82          * Constructs a new InvoiceError given each field
83          * 
84          * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
85          */
86         public static InvoiceError of(@Nullable org.ldk.structs.ErroneousField erroneous_field_arg, org.ldk.structs.UntrustedString message_arg) {
87                 long ret = bindings.InvoiceError_new(erroneous_field_arg == null ? 0 : erroneous_field_arg.ptr, message_arg == null ? 0 : message_arg.ptr);
88                 Reference.reachabilityFence(erroneous_field_arg);
89                 Reference.reachabilityFence(message_arg);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.InvoiceError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceError(null, ret); }
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(erroneous_field_arg); };
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(message_arg); };
95                 return ret_hu_conv;
96         }
97
98         long clone_ptr() {
99                 long ret = bindings.InvoiceError_clone_ptr(this.ptr);
100                 Reference.reachabilityFence(this);
101                 return ret;
102         }
103
104         /**
105          * Creates a copy of the InvoiceError
106          */
107         public InvoiceError clone() {
108                 long ret = bindings.InvoiceError_clone(this.ptr);
109                 Reference.reachabilityFence(this);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 org.ldk.structs.InvoiceError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceError(null, ret); }
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
113                 return ret_hu_conv;
114         }
115
116         /**
117          * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read
118          */
119         public byte[] write() {
120                 byte[] ret = bindings.InvoiceError_write(this.ptr);
121                 Reference.reachabilityFence(this);
122                 return ret;
123         }
124
125         /**
126          * Read a InvoiceError from a byte array, created by InvoiceError_write
127          */
128         public static Result_InvoiceErrorDecodeErrorZ read(byte[] ser) {
129                 long ret = bindings.InvoiceError_read(ser);
130                 Reference.reachabilityFence(ser);
131                 if (ret >= 0 && ret <= 4096) { return null; }
132                 Result_InvoiceErrorDecodeErrorZ ret_hu_conv = Result_InvoiceErrorDecodeErrorZ.constr_from_ptr(ret);
133                 return ret_hu_conv;
134         }
135
136 }