[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / src / main / java / org / ldk / structs / Quantity.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  * Quantity of items supported by an [`Offer`].
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Quantity extends CommonBase {
16         private Quantity(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Quantity_free(ptr); }
21         }
22         static Quantity constr_from_ptr(long ptr) {
23                 bindings.LDKQuantity raw_val = bindings.LDKQuantity_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKQuantity.Bounded.class) {
25                         return new Bounded(ptr, (bindings.LDKQuantity.Bounded)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKQuantity.Unbounded.class) {
28                         return new Unbounded(ptr, (bindings.LDKQuantity.Unbounded)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKQuantity.One.class) {
31                         return new One(ptr, (bindings.LDKQuantity.One)raw_val);
32                 }
33                 assert false; return null; // Unreachable without extending the (internal) bindings interface
34         }
35
36         /**
37          * Up to a specific number of items (inclusive). Use when more than one item can be requested
38          * but is limited (e.g., because of per customer or inventory limits).
39          * 
40          * May be used with `NonZeroU64::new(1)` but prefer to use [`Quantity::One`] if only one item
41          * is supported.
42          */
43         public final static class Bounded extends Quantity {
44                 public final long bounded;
45                 private Bounded(long ptr, bindings.LDKQuantity.Bounded obj) {
46                         super(null, ptr);
47                         this.bounded = obj.bounded;
48                 }
49         }
50         /**
51          * One or more items. Use when more than one item can be requested without any limit.
52          */
53         public final static class Unbounded extends Quantity {
54                 private Unbounded(long ptr, bindings.LDKQuantity.Unbounded obj) {
55                         super(null, ptr);
56                 }
57         }
58         /**
59          * Only one item. Use when only a single item can be requested.
60          */
61         public final static class One extends Quantity {
62                 private One(long ptr, bindings.LDKQuantity.One obj) {
63                         super(null, ptr);
64                 }
65         }
66         long clone_ptr() {
67                 long ret = bindings.Quantity_clone_ptr(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         /**
73          * Creates a copy of the Quantity
74          */
75         public Quantity clone() {
76                 long ret = bindings.Quantity_clone(this.ptr);
77                 Reference.reachabilityFence(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Utility method to constructs a new Bounded-variant Quantity
86          */
87         public static Quantity bounded(long a) {
88                 long ret = bindings.Quantity_bounded(a);
89                 Reference.reachabilityFence(a);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Utility method to constructs a new Unbounded-variant Quantity
98          */
99         public static Quantity unbounded() {
100                 long ret = bindings.Quantity_unbounded();
101                 if (ret >= 0 && ret <= 4096) { return null; }
102                 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
103                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
104                 return ret_hu_conv;
105         }
106
107         /**
108          * Utility method to constructs a new One-variant Quantity
109          */
110         public static Quantity one() {
111                 long ret = bindings.Quantity_one();
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
115                 return ret_hu_conv;
116         }
117
118 }