[Java] Update auto-generated Java bindings
[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         public void set_addresses(NetAddress[] val) {
111                 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
112                 Reference.reachabilityFence(this);
113                 Reference.reachabilityFence(val);
114         }
115
116         /**
117          * An initial announcement of the node
118          * Mostly redundant with the data we store in fields explicitly.
119          * Everything else is useful only for sending out for initial routing sync.
120          * Not stored if contains excess data to prevent DoS.
121          * 
122          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
123          */
124         @Nullable
125         public NodeAnnouncement get_announcement_message() {
126                 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
127                 Reference.reachabilityFence(this);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
130                 ret_hu_conv.ptrs_to.add(this);
131                 return ret_hu_conv;
132         }
133
134         /**
135          * An initial announcement of the node
136          * Mostly redundant with the data we store in fields explicitly.
137          * Everything else is useful only for sending out for initial routing sync.
138          * Not stored if contains excess data to prevent DoS.
139          * 
140          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
141          */
142         public void set_announcement_message(@Nullable NodeAnnouncement val) {
143                 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
144                 Reference.reachabilityFence(this);
145                 Reference.reachabilityFence(val);
146         }
147
148         /**
149          * Constructs a new NodeAnnouncementInfo given each field
150          */
151         public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, NodeAlias alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
152                 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);
153                 Reference.reachabilityFence(features_arg);
154                 Reference.reachabilityFence(last_update_arg);
155                 Reference.reachabilityFence(rgb_arg);
156                 Reference.reachabilityFence(alias_arg);
157                 Reference.reachabilityFence(addresses_arg);
158                 Reference.reachabilityFence(announcement_message_arg);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
161                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
162                 return ret_hu_conv;
163         }
164
165         long clone_ptr() {
166                 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
167                 Reference.reachabilityFence(this);
168                 return ret;
169         }
170
171         /**
172          * Creates a copy of the NodeAnnouncementInfo
173          */
174         public NodeAnnouncementInfo clone() {
175                 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
176                 Reference.reachabilityFence(this);
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
179                 ret_hu_conv.ptrs_to.add(this);
180                 return ret_hu_conv;
181         }
182
183         /**
184          * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
185          */
186         public byte[] write() {
187                 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
188                 Reference.reachabilityFence(this);
189                 return ret;
190         }
191
192         /**
193          * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
194          */
195         public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
196                 long ret = bindings.NodeAnnouncementInfo_read(ser);
197                 Reference.reachabilityFence(ser);
198                 if (ret >= 0 && ret <= 4096) { return null; }
199                 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
200                 return ret_hu_conv;
201         }
202
203 }