Update auto-generated bindings to latest upstream
[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 < 1024) { return null; }
28                 NodeFeatures 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                 this.ptrs_to.add(val);
39         }
40
41         /**
42          * When the last known update to the node state was issued.
43          * Value is opaque, as set in the announcement.
44          */
45         public int get_last_update() {
46                 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
47                 return ret;
48         }
49
50         /**
51          * When the last known update to the node state was issued.
52          * Value is opaque, as set in the announcement.
53          */
54         public void set_last_update(int val) {
55                 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
56         }
57
58         /**
59          * Color assigned to the node
60          */
61         public byte[] get_rgb() {
62                 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
63                 return ret;
64         }
65
66         /**
67          * Color assigned to the node
68          */
69         public void set_rgb(byte[] val) {
70                 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, val);
71         }
72
73         /**
74          * Moniker assigned to the node.
75          * May be invalid or malicious (eg control chars),
76          * should not be exposed to the user.
77          */
78         public byte[] get_alias() {
79                 byte[] ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
80                 return ret;
81         }
82
83         /**
84          * Moniker assigned to the node.
85          * May be invalid or malicious (eg control chars),
86          * should not be exposed to the user.
87          */
88         public void set_alias(byte[] val) {
89                 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val);
90         }
91
92         /**
93          * Internet-level addresses via which one can connect to the node
94          */
95         public void set_addresses(NetAddress[] val) {
96                 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
97                 /* TODO 2 NetAddress  */;
98         }
99
100         /**
101          * An initial announcement of the node
102          * Mostly redundant with the data we store in fields explicitly.
103          * Everything else is useful only for sending out for initial routing sync.
104          * Not stored if contains excess data to prevent DoS.
105          * 
106          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
107          */
108         @Nullable
109         public NodeAnnouncement get_announcement_message() {
110                 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
111                 if (ret < 1024) { return null; }
112                 NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
113                 ret_hu_conv.ptrs_to.add(this);
114                 return ret_hu_conv;
115         }
116
117         /**
118          * An initial announcement of the node
119          * Mostly redundant with the data we store in fields explicitly.
120          * Everything else is useful only for sending out for initial routing sync.
121          * Not stored if contains excess data to prevent DoS.
122          * 
123          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
124          */
125         public void set_announcement_message(@Nullable NodeAnnouncement val) {
126                 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
127                 this.ptrs_to.add(val);
128         }
129
130         /**
131          * Constructs a new NodeAnnouncementInfo given each field
132          */
133         public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
134                 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);
135                 if (ret < 1024) { return null; }
136                 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
137                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
138                 ret_hu_conv.ptrs_to.add(features_arg);
139                 /* TODO 2 NetAddress  */;
140                 ret_hu_conv.ptrs_to.add(announcement_message_arg);
141                 return ret_hu_conv;
142         }
143
144         /**
145          * Creates a copy of the NodeAnnouncementInfo
146          */
147         public NodeAnnouncementInfo clone() {
148                 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
149                 if (ret < 1024) { return null; }
150                 NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
151                 ret_hu_conv.ptrs_to.add(this);
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
157          */
158         public byte[] write() {
159                 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
160                 return ret;
161         }
162
163         /**
164          * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
165          */
166         public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
167                 long ret = bindings.NodeAnnouncementInfo_read(ser);
168                 if (ret < 1024) { return null; }
169                 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
170                 return ret_hu_conv;
171         }
172
173 }