[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / UnsignedNodeAnnouncement.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  * The unsigned part of a [`node_announcement`] message.
13  * 
14  * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UnsignedNodeAnnouncement extends CommonBase {
18         UnsignedNodeAnnouncement(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.UnsignedNodeAnnouncement_free(ptr); }
23         }
24
25         /**
26          * The advertised features
27          */
28         public NodeFeatures get_features() {
29                 long ret = bindings.UnsignedNodeAnnouncement_get_features(this.ptr);
30                 Reference.reachabilityFence(this);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * The advertised features
39          */
40         public void set_features(org.ldk.structs.NodeFeatures val) {
41                 bindings.UnsignedNodeAnnouncement_set_features(this.ptr, val == null ? 0 : val.ptr);
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44                 if (this != null) { this.ptrs_to.add(val); };
45         }
46
47         /**
48          * A strictly monotonic announcement counter, with gaps allowed
49          */
50         public int get_timestamp() {
51                 int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * A strictly monotonic announcement counter, with gaps allowed
58          */
59         public void set_timestamp(int val) {
60                 bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
67          * to this node).
68          */
69         public NodeId get_node_id() {
70                 long ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr);
71                 Reference.reachabilityFence(this);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
80          * to this node).
81          */
82         public void set_node_id(org.ldk.structs.NodeId val) {
83                 bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, val == null ? 0 : val.ptr);
84                 Reference.reachabilityFence(this);
85                 Reference.reachabilityFence(val);
86                 if (this != null) { this.ptrs_to.add(val); };
87         }
88
89         /**
90          * An RGB color for UI purposes
91          */
92         public byte[] get_rgb() {
93                 byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
94                 Reference.reachabilityFence(this);
95                 return ret;
96         }
97
98         /**
99          * An RGB color for UI purposes
100          */
101         public void set_rgb(byte[] val) {
102                 bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(val);
105         }
106
107         /**
108          * An alias, for UI purposes.
109          * 
110          * This should be sanitized before use. There is no guarantee of uniqueness.
111          */
112         public NodeAlias get_alias() {
113                 long ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr);
114                 Reference.reachabilityFence(this);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
118                 return ret_hu_conv;
119         }
120
121         /**
122          * An alias, for UI purposes.
123          * 
124          * This should be sanitized before use. There is no guarantee of uniqueness.
125          */
126         public void set_alias(org.ldk.structs.NodeAlias val) {
127                 bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, val == null ? 0 : val.ptr);
128                 Reference.reachabilityFence(this);
129                 Reference.reachabilityFence(val);
130                 if (this != null) { this.ptrs_to.add(val); };
131         }
132
133         /**
134          * List of addresses on which this node is reachable
135          * 
136          * Returns a copy of the field.
137          */
138         public SocketAddress[] get_addresses() {
139                 long[] ret = bindings.UnsignedNodeAnnouncement_get_addresses(this.ptr);
140                 Reference.reachabilityFence(this);
141                 int ret_conv_15_len = ret.length;
142                 SocketAddress[] ret_conv_15_arr = new SocketAddress[ret_conv_15_len];
143                 for (int p = 0; p < ret_conv_15_len; p++) {
144                         long ret_conv_15 = ret[p];
145                         org.ldk.structs.SocketAddress ret_conv_15_hu_conv = org.ldk.structs.SocketAddress.constr_from_ptr(ret_conv_15);
146                         if (ret_conv_15_hu_conv != null) { ret_conv_15_hu_conv.ptrs_to.add(this); };
147                         ret_conv_15_arr[p] = ret_conv_15_hu_conv;
148                 }
149                 return ret_conv_15_arr;
150         }
151
152         /**
153          * List of addresses on which this node is reachable
154          */
155         public void set_addresses(SocketAddress[] val) {
156                 bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15.ptr).toArray() : null);
157                 Reference.reachabilityFence(this);
158                 Reference.reachabilityFence(val);
159                 for (SocketAddress val_conv_15: val) { if (this != null) { this.ptrs_to.add(val_conv_15); }; };
160         }
161
162         long clone_ptr() {
163                 long ret = bindings.UnsignedNodeAnnouncement_clone_ptr(this.ptr);
164                 Reference.reachabilityFence(this);
165                 return ret;
166         }
167
168         /**
169          * Creates a copy of the UnsignedNodeAnnouncement
170          */
171         public UnsignedNodeAnnouncement clone() {
172                 long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
173                 Reference.reachabilityFence(this);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
176                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
182          */
183         public long hash() {
184                 long ret = bindings.UnsignedNodeAnnouncement_hash(this.ptr);
185                 Reference.reachabilityFence(this);
186                 return ret;
187         }
188
189         @Override public int hashCode() {
190                 return (int)this.hash();
191         }
192         /**
193          * Checks if two UnsignedNodeAnnouncements contain equal inner contents.
194          * This ignores pointers and is_owned flags and looks at the values in fields.
195          * Two objects with NULL inner values will be considered "equal" here.
196          */
197         public boolean eq(org.ldk.structs.UnsignedNodeAnnouncement b) {
198                 boolean ret = bindings.UnsignedNodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
199                 Reference.reachabilityFence(this);
200                 Reference.reachabilityFence(b);
201                 if (this != null) { this.ptrs_to.add(b); };
202                 return ret;
203         }
204
205         @Override public boolean equals(Object o) {
206                 if (!(o instanceof UnsignedNodeAnnouncement)) return false;
207                 return this.eq((UnsignedNodeAnnouncement)o);
208         }
209         /**
210          * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
211          */
212         public byte[] write() {
213                 byte[] ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
214                 Reference.reachabilityFence(this);
215                 return ret;
216         }
217
218         /**
219          * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
220          */
221         public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
222                 long ret = bindings.UnsignedNodeAnnouncement_read(ser);
223                 Reference.reachabilityFence(ser);
224                 if (ret >= 0 && ret <= 4096) { return null; }
225                 Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
226                 return ret_hu_conv;
227         }
228
229 }