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