Update auto-generated bindings to 0.0.103
[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 javax.annotation.Nullable;
8
9
10 /**
11  * Information received in the latest node_announcement from this node.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class NodeAnnouncementInfo extends CommonBase {
15         NodeAnnouncementInfo(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.NodeAnnouncementInfo_free(ptr); }
20         }
21
22         /**
23          * Protocol features the node announced support for
24          */
25         public NodeFeatures get_features() {
26                 long ret = bindings.NodeAnnouncementInfo_get_features(this.ptr);
27                 if (ret >= 0 && ret <= 4096) { return null; }
28                 NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
29                 ret_hu_conv.ptrs_to.add(this);
30                 return ret_hu_conv;
31         }
32
33         /**
34          * Protocol features the node announced support for
35          */
36         public void set_features(NodeFeatures val) {
37                 bindings.NodeAnnouncementInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
38         }
39
40         /**
41          * When the last known update to the node state was issued.
42          * Value is opaque, as set in the announcement.
43          */
44         public int get_last_update() {
45                 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
46                 return ret;
47         }
48
49         /**
50          * When the last known update to the node state was issued.
51          * Value is opaque, as set in the announcement.
52          */
53         public void set_last_update(int val) {
54                 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
55         }
56
57         /**
58          * Color assigned to the node
59          */
60         public byte[] get_rgb() {
61                 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
62                 return ret;
63         }
64
65         /**
66          * Color assigned to the node
67          */
68         public void set_rgb(byte[] val) {
69                 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, val);
70         }
71
72         /**
73          * Moniker assigned to the node.
74          * May be invalid or malicious (eg control chars),
75          * should not be exposed to the user.
76          */
77         public byte[] get_alias() {
78                 byte[] ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
79                 return ret;
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 void set_alias(byte[] val) {
88                 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val);
89         }
90
91         /**
92          * Internet-level addresses via which one can connect to the node
93          */
94         public void set_addresses(NetAddress[] val) {
95                 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
96         }
97
98         /**
99          * An initial announcement of the node
100          * Mostly redundant with the data we store in fields explicitly.
101          * Everything else is useful only for sending out for initial routing sync.
102          * Not stored if contains excess data to prevent DoS.
103          * 
104          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
105          */
106         @Nullable
107         public NodeAnnouncement get_announcement_message() {
108                 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncement(null, ret); }
111                 ret_hu_conv.ptrs_to.add(this);
112                 return ret_hu_conv;
113         }
114
115         /**
116          * An initial announcement of the node
117          * Mostly redundant with the data we store in fields explicitly.
118          * Everything else is useful only for sending out for initial routing sync.
119          * Not stored if contains excess data to prevent DoS.
120          * 
121          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
122          */
123         public void set_announcement_message(@Nullable NodeAnnouncement val) {
124                 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
125         }
126
127         /**
128          * Constructs a new NodeAnnouncementInfo given each field
129          */
130         public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
131                 long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, last_update_arg, rgb_arg, alias_arg, 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);
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
134                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Creates a copy of the NodeAnnouncementInfo
140          */
141         public NodeAnnouncementInfo clone() {
142                 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
145                 ret_hu_conv.ptrs_to.add(this);
146                 return ret_hu_conv;
147         }
148
149         /**
150          * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
151          */
152         public byte[] write() {
153                 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
154                 return ret;
155         }
156
157         /**
158          * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
159          */
160         public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
161                 long ret = bindings.NodeAnnouncementInfo_read(ser);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
164                 return ret_hu_conv;
165         }
166
167 }