[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / InvoiceRequestWithExplicitPayerIdBuilder.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  * Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow.
13  * 
14  * See [module-level documentation] for usage.
15  * 
16  * [module-level documentation]: self
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class InvoiceRequestWithExplicitPayerIdBuilder extends CommonBase {
20         InvoiceRequestWithExplicitPayerIdBuilder(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.InvoiceRequestWithExplicitPayerIdBuilder_free(ptr); }
25         }
26
27         /**
28          * Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed
29          * by [`UnsignedInvoiceRequest::sign`].
30          */
31         public Result_UnsignedInvoiceRequestBolt12SemanticErrorZ build() {
32                 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_build(this.ptr);
33                 Reference.reachabilityFence(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 Result_UnsignedInvoiceRequestBolt12SemanticErrorZ ret_hu_conv = Result_UnsignedInvoiceRequestBolt12SemanticErrorZ.constr_from_ptr(ret);
36                 if (this != null) { this.ptrs_to.add(this); };
37                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
38                 // an object to pass exclusive ownership to the function being called.
39                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
40                 // at the FFI layer, creating a new object which Rust can claim ownership of
41                 // However, in some cases (eg here), there is no way to clone an object, and thus
42                 // we actually have to pass full ownership to Rust.
43                 // Thus, after this call, this is reset to null and is now a dummy object.
44                 this.ptr = 0;;
45                 return ret_hu_conv;
46         }
47
48         /**
49          * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not
50          * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported
51          * by the offer.
52          * 
53          * Successive calls to this method will override the previous setting.
54          */
55         public Result_NoneBolt12SemanticErrorZ chain(org.ldk.enums.Network network) {
56                 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_chain(this.ptr, network);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(network);
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
61                 if (this != null) { this.ptrs_to.add(this); };
62                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
63                 // an object to pass exclusive ownership to the function being called.
64                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
65                 // at the FFI layer, creating a new object which Rust can claim ownership of
66                 // However, in some cases (eg here), there is no way to clone an object, and thus
67                 // we actually have to pass full ownership to Rust.
68                 // Thus, after this call, this is reset to null and is now a dummy object.
69                 this.ptr = 0;;
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is
75          * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]).
76          * 
77          * Successive calls to this method will override the previous setting.
78          * 
79          * [`quantity`]: Self::quantity
80          */
81         public Result_NoneBolt12SemanticErrorZ amount_msats(long amount_msats) {
82                 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_amount_msats(this.ptr, amount_msats);
83                 Reference.reachabilityFence(this);
84                 Reference.reachabilityFence(amount_msats);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
87                 if (this != null) { this.ptrs_to.add(this); };
88                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
89                 // an object to pass exclusive ownership to the function being called.
90                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
91                 // at the FFI layer, creating a new object which Rust can claim ownership of
92                 // However, in some cases (eg here), there is no way to clone an object, and thus
93                 // we actually have to pass full ownership to Rust.
94                 // Thus, after this call, this is reset to null and is now a dummy object.
95                 this.ptr = 0;;
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity`
101          * does not conform to [`Offer::is_valid_quantity`].
102          * 
103          * Successive calls to this method will override the previous setting.
104          */
105         public Result_NoneBolt12SemanticErrorZ quantity(long quantity) {
106                 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_quantity(this.ptr, quantity);
107                 Reference.reachabilityFence(this);
108                 Reference.reachabilityFence(quantity);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
111                 if (this != null) { this.ptrs_to.add(this); };
112                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
113                 // an object to pass exclusive ownership to the function being called.
114                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
115                 // at the FFI layer, creating a new object which Rust can claim ownership of
116                 // However, in some cases (eg here), there is no way to clone an object, and thus
117                 // we actually have to pass full ownership to Rust.
118                 // Thus, after this call, this is reset to null and is now a dummy object.
119                 this.ptr = 0;;
120                 return ret_hu_conv;
121         }
122
123         /**
124          * Sets the [`InvoiceRequest::payer_note`].
125          * 
126          * Successive calls to this method will override the previous setting.
127          */
128         public void payer_note(java.lang.String payer_note) {
129                 bindings.InvoiceRequestWithExplicitPayerIdBuilder_payer_note(this.ptr, payer_note);
130                 Reference.reachabilityFence(this);
131                 Reference.reachabilityFence(payer_note);
132                 if (this != null) { this.ptrs_to.add(this); };
133                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
134                 // an object to pass exclusive ownership to the function being called.
135                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
136                 // at the FFI layer, creating a new object which Rust can claim ownership of
137                 // However, in some cases (eg here), there is no way to clone an object, and thus
138                 // we actually have to pass full ownership to Rust.
139                 // Thus, after this call, this is reset to null and is now a dummy object.
140                 this.ptr = 0;;
141         }
142
143 }