Update auto-updated Java files
[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                 NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new 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 byte[] get_alias() {
88                 byte[] ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * Moniker assigned to the node.
95          * May be invalid or malicious (eg control chars),
96          * should not be exposed to the user.
97          */
98         public void set_alias(byte[] val) {
99                 bindings.NodeAnnouncementInfo_set_alias(this.ptr, InternalUtils.check_arr_len(val, 32));
100                 Reference.reachabilityFence(this);
101                 Reference.reachabilityFence(val);
102         }
103
104         /**
105          * Internet-level addresses via which one can connect to the node
106          */
107         public void set_addresses(NetAddress[] val) {
108                 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
109                 Reference.reachabilityFence(this);
110                 Reference.reachabilityFence(val);
111         }
112
113         /**
114          * An initial announcement of the node
115          * Mostly redundant with the data we store in fields explicitly.
116          * Everything else is useful only for sending out for initial routing sync.
117          * Not stored if contains excess data to prevent DoS.
118          * 
119          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
120          */
121         @Nullable
122         public NodeAnnouncement get_announcement_message() {
123                 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
124                 Reference.reachabilityFence(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncement(null, ret); }
127                 ret_hu_conv.ptrs_to.add(this);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * An initial announcement of the node
133          * Mostly redundant with the data we store in fields explicitly.
134          * Everything else is useful only for sending out for initial routing sync.
135          * Not stored if contains excess data to prevent DoS.
136          * 
137          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
138          */
139         public void set_announcement_message(@Nullable NodeAnnouncement val) {
140                 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
141                 Reference.reachabilityFence(this);
142                 Reference.reachabilityFence(val);
143         }
144
145         /**
146          * Constructs a new NodeAnnouncementInfo given each field
147          */
148         public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
149                 long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, last_update_arg, InternalUtils.check_arr_len(rgb_arg, 3), InternalUtils.check_arr_len(alias_arg, 32), 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);
150                 Reference.reachabilityFence(features_arg);
151                 Reference.reachabilityFence(last_update_arg);
152                 Reference.reachabilityFence(rgb_arg);
153                 Reference.reachabilityFence(alias_arg);
154                 Reference.reachabilityFence(addresses_arg);
155                 Reference.reachabilityFence(announcement_message_arg);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
158                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
159                 return ret_hu_conv;
160         }
161
162         long clone_ptr() {
163                 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
164                 Reference.reachabilityFence(this);
165                 return ret;
166         }
167
168         /**
169          * Creates a copy of the NodeAnnouncementInfo
170          */
171         public NodeAnnouncementInfo clone() {
172                 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
173                 Reference.reachabilityFence(this);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
176                 ret_hu_conv.ptrs_to.add(this);
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
182          */
183         public byte[] write() {
184                 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
185                 Reference.reachabilityFence(this);
186                 return ret;
187         }
188
189         /**
190          * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
191          */
192         public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
193                 long ret = bindings.NodeAnnouncementInfo_read(ser);
194                 Reference.reachabilityFence(ser);
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
197                 return ret_hu_conv;
198         }
199
200 }