[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / ChannelFeatures.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  * Features used within a `channel_announcement` message.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelFeatures extends CommonBase {
16         ChannelFeatures(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ChannelFeatures_free(ptr); }
21         }
22
23         /**
24          * Checks if two ChannelFeaturess contain equal inner contents.
25          * This ignores pointers and is_owned flags and looks at the values in fields.
26          * Two objects with NULL inner values will be considered "equal" here.
27          */
28         public boolean eq(org.ldk.structs.ChannelFeatures b) {
29                 boolean ret = bindings.ChannelFeatures_eq(this.ptr, b == null ? 0 : b.ptr);
30                 Reference.reachabilityFence(this);
31                 Reference.reachabilityFence(b);
32                 if (this != null) { this.ptrs_to.add(b); };
33                 return ret;
34         }
35
36         @Override public boolean equals(Object o) {
37                 if (!(o instanceof ChannelFeatures)) return false;
38                 return this.eq((ChannelFeatures)o);
39         }
40         long clone_ptr() {
41                 long ret = bindings.ChannelFeatures_clone_ptr(this.ptr);
42                 Reference.reachabilityFence(this);
43                 return ret;
44         }
45
46         /**
47          * Creates a copy of the ChannelFeatures
48          */
49         public ChannelFeatures clone() {
50                 long ret = bindings.ChannelFeatures_clone(this.ptr);
51                 Reference.reachabilityFence(this);
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
54                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Generates a non-cryptographic 64-bit hash of the ChannelFeatures.
60          */
61         public long hash() {
62                 long ret = bindings.ChannelFeatures_hash(this.ptr);
63                 Reference.reachabilityFence(this);
64                 return ret;
65         }
66
67         @Override public int hashCode() {
68                 return (int)this.hash();
69         }
70         /**
71          * Create a blank Features with no features set
72          */
73         public static ChannelFeatures empty() {
74                 long ret = bindings.ChannelFeatures_empty();
75                 if (ret >= 0 && ret <= 4096) { return null; }
76                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
77                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
78                 return ret_hu_conv;
79         }
80
81         /**
82          * Returns true if this `Features` object contains required features unknown by `other`.
83          */
84         public boolean requires_unknown_bits_from(org.ldk.structs.ChannelFeatures other) {
85                 boolean ret = bindings.ChannelFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
86                 Reference.reachabilityFence(this);
87                 Reference.reachabilityFence(other);
88                 if (this != null) { this.ptrs_to.add(other); };
89                 return ret;
90         }
91
92         /**
93          * Returns true if this `Features` object contains unknown feature flags which are set as
94          * \"required\".
95          */
96         public boolean requires_unknown_bits() {
97                 boolean ret = bindings.ChannelFeatures_requires_unknown_bits(this.ptr);
98                 Reference.reachabilityFence(this);
99                 return ret;
100         }
101
102         /**
103          * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
104          * by [BOLT 9].
105          * 
106          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
107          * be set instead (i.e., `bit - 1`).
108          * 
109          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
110          */
111         public Result_NoneNoneZ set_required_feature_bit(long bit) {
112                 long ret = bindings.ChannelFeatures_set_required_feature_bit(this.ptr, bit);
113                 Reference.reachabilityFence(this);
114                 Reference.reachabilityFence(bit);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
117                 return ret_hu_conv;
118         }
119
120         /**
121          * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
122          * by [BOLT 9].
123          * 
124          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
125          * set instead (i.e., `bit + 1`).
126          * 
127          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
128          */
129         public Result_NoneNoneZ set_optional_feature_bit(long bit) {
130                 long ret = bindings.ChannelFeatures_set_optional_feature_bit(this.ptr, bit);
131                 Reference.reachabilityFence(this);
132                 Reference.reachabilityFence(bit);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
140          * by [bLIP 2] or if it is a known `T` feature.
141          * 
142          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
143          * be set instead (i.e., `bit - 1`).
144          * 
145          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
146          */
147         public Result_NoneNoneZ set_required_custom_bit(long bit) {
148                 long ret = bindings.ChannelFeatures_set_required_custom_bit(this.ptr, bit);
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(bit);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
153                 return ret_hu_conv;
154         }
155
156         /**
157          * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
158          * by [bLIP 2] or if it is a known `T` feature.
159          * 
160          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
161          * set instead (i.e., `bit + 1`).
162          * 
163          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
164          */
165         public Result_NoneNoneZ set_optional_custom_bit(long bit) {
166                 long ret = bindings.ChannelFeatures_set_optional_custom_bit(this.ptr, bit);
167                 Reference.reachabilityFence(this);
168                 Reference.reachabilityFence(bit);
169                 if (ret >= 0 && ret <= 4096) { return null; }
170                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
171                 return ret_hu_conv;
172         }
173
174         /**
175          * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read
176          */
177         public byte[] write() {
178                 byte[] ret = bindings.ChannelFeatures_write(this.ptr);
179                 Reference.reachabilityFence(this);
180                 return ret;
181         }
182
183         /**
184          * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write
185          */
186         public static Result_ChannelFeaturesDecodeErrorZ read(byte[] ser) {
187                 long ret = bindings.ChannelFeatures_read(ser);
188                 Reference.reachabilityFence(ser);
189                 if (ret >= 0 && ret <= 4096) { return null; }
190                 Result_ChannelFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelFeaturesDecodeErrorZ.constr_from_ptr(ret);
191                 return ret_hu_conv;
192         }
193
194 }