[Java] Update auto-generated Java bindings with new upstream getters
[ldk-java] / src / main / java / org / ldk / structs / NodeAnnouncementInfo.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  * Information received in the latest node_announcement from this node.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class NodeAnnouncementInfo extends CommonBase {
16         NodeAnnouncementInfo(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.NodeAnnouncementInfo_free(ptr); }
21         }
22
23         /**
24          * Protocol features the node announced support for
25          */
26         public NodeFeatures get_features() {
27                 long ret = bindings.NodeAnnouncementInfo_get_features(this.ptr);
28                 Reference.reachabilityFence(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
31                 ret_hu_conv.ptrs_to.add(this);
32                 return ret_hu_conv;
33         }
34
35         /**
36          * Protocol features the node announced support for
37          */
38         public void set_features(NodeFeatures val) {
39                 bindings.NodeAnnouncementInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42         }
43
44         /**
45          * When the last known update to the node state was issued.
46          * Value is opaque, as set in the announcement.
47          */
48         public int get_last_update() {
49                 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * When the last known update to the node state was issued.
56          * Value is opaque, as set in the announcement.
57          */
58         public void set_last_update(int val) {
59                 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
60                 Reference.reachabilityFence(this);
61                 Reference.reachabilityFence(val);
62         }
63
64         /**
65          * Color assigned to the node
66          */
67         public byte[] get_rgb() {
68                 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
69                 Reference.reachabilityFence(this);
70                 return ret;
71         }
72
73         /**
74          * Color assigned to the node
75          */
76         public void set_rgb(byte[] val) {
77                 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
78                 Reference.reachabilityFence(this);
79                 Reference.reachabilityFence(val);
80         }
81
82         /**
83          * Moniker assigned to the node.
84          * May be invalid or malicious (eg control chars),
85          * should not be exposed to the user.
86          */
87         public NodeAlias get_alias() {
88                 long ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
89                 Reference.reachabilityFence(this);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
92                 ret_hu_conv.ptrs_to.add(this);
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Moniker assigned to the node.
98          * May be invalid or malicious (eg control chars),
99          * should not be exposed to the user.
100          */
101         public void set_alias(NodeAlias val) {
102                 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val == null ? 0 : val.ptr & ~1);
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(val);
105         }
106
107         /**
108          * Internet-level addresses via which one can connect to the node
109          * 
110          * Returns a copy of the field.
111          */
112         public NetAddress[] get_addresses() {
113                 long[] ret = bindings.NodeAnnouncementInfo_get_addresses(this.ptr);
114                 Reference.reachabilityFence(this);
115                 int ret_conv_12_len = ret.length;
116                 NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
117                 for (int m = 0; m < ret_conv_12_len; m++) {
118                         long ret_conv_12 = ret[m];
119                         org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
120                         ret_conv_12_hu_conv.ptrs_to.add(this);
121                         ret_conv_12_arr[m] = ret_conv_12_hu_conv;
122                 }
123                 return ret_conv_12_arr;
124         }
125
126         /**
127          * Internet-level addresses via which one can connect to the node
128          */
129         public void set_addresses(NetAddress[] val) {
130                 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
131                 Reference.reachabilityFence(this);
132                 Reference.reachabilityFence(val);
133         }
134
135         /**
136          * An initial announcement of the node
137          * Mostly redundant with the data we store in fields explicitly.
138          * Everything else is useful only for sending out for initial routing sync.
139          * Not stored if contains excess data to prevent DoS.
140          * 
141          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
142          */
143         @Nullable
144         public NodeAnnouncement get_announcement_message() {
145                 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
146                 Reference.reachabilityFence(this);
147                 if (ret >= 0 && ret <= 4096) { return null; }
148                 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
149                 ret_hu_conv.ptrs_to.add(this);
150                 return ret_hu_conv;
151         }
152
153         /**
154          * An initial announcement of the node
155          * Mostly redundant with the data we store in fields explicitly.
156          * Everything else is useful only for sending out for initial routing sync.
157          * Not stored if contains excess data to prevent DoS.
158          * 
159          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
160          */
161         public void set_announcement_message(@Nullable NodeAnnouncement val) {
162                 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
163                 Reference.reachabilityFence(this);
164                 Reference.reachabilityFence(val);
165         }
166
167         /**
168          * Constructs a new NodeAnnouncementInfo given each field
169          */
170         public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, NodeAlias alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
171                 long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, last_update_arg, InternalUtils.check_arr_len(rgb_arg, 3), alias_arg == null ? 0 : alias_arg.ptr & ~1, addresses_arg != null ? Arrays.stream(addresses_arg).mapToLong(addresses_arg_conv_12 -> addresses_arg_conv_12.ptr).toArray() : null, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
172                 Reference.reachabilityFence(features_arg);
173                 Reference.reachabilityFence(last_update_arg);
174                 Reference.reachabilityFence(rgb_arg);
175                 Reference.reachabilityFence(alias_arg);
176                 Reference.reachabilityFence(addresses_arg);
177                 Reference.reachabilityFence(announcement_message_arg);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
180                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
181                 return ret_hu_conv;
182         }
183
184         long clone_ptr() {
185                 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
186                 Reference.reachabilityFence(this);
187                 return ret;
188         }
189
190         /**
191          * Creates a copy of the NodeAnnouncementInfo
192          */
193         public NodeAnnouncementInfo clone() {
194                 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
195                 Reference.reachabilityFence(this);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
198                 ret_hu_conv.ptrs_to.add(this);
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
204          */
205         public byte[] write() {
206                 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
207                 Reference.reachabilityFence(this);
208                 return ret;
209         }
210
211         /**
212          * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
213          */
214         public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
215                 long ret = bindings.NodeAnnouncementInfo_read(ser);
216                 Reference.reachabilityFence(ser);
217                 if (ret >= 0 && ret <= 4096) { return null; }
218                 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
219                 return ret_hu_conv;
220         }
221
222 }