[Java] Update auto-generated Java bindings
[ldk-java] / src / main / java / org / ldk / structs / NodeInfo.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  * Details about a node in the network, known from the network announcement.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class NodeInfo extends CommonBase {
16         NodeInfo(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.NodeInfo_free(ptr); }
21         }
22
23         /**
24          * All valid channels a node has announced
25          * 
26          * Returns a copy of the field.
27          */
28         public long[] get_channels() {
29                 long[] ret = bindings.NodeInfo_get_channels(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * All valid channels a node has announced
36          */
37         public void set_channels(long[] val) {
38                 bindings.NodeInfo_set_channels(this.ptr, val);
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * Lowest fees enabling routing via any of the enabled, known channels to a node.
45          * The two fields (flat and proportional fee) are independent,
46          * meaning they don't have to refer to the same channel.
47          * 
48          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
49          */
50         @Nullable
51         public RoutingFees get_lowest_inbound_channel_fees() {
52                 long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr);
53                 Reference.reachabilityFence(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
56                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
57                 return ret_hu_conv;
58         }
59
60         /**
61          * Lowest fees enabling routing via any of the enabled, known channels to a node.
62          * The two fields (flat and proportional fee) are independent,
63          * meaning they don't have to refer to the same channel.
64          * 
65          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
66          */
67         public void set_lowest_inbound_channel_fees(@Nullable RoutingFees val) {
68                 bindings.NodeInfo_set_lowest_inbound_channel_fees(this.ptr, val == null ? 0 : val.ptr);
69                 Reference.reachabilityFence(this);
70                 Reference.reachabilityFence(val);
71                 if (this != null) { this.ptrs_to.add(val); };
72         }
73
74         /**
75          * More information about a node from node_announcement.
76          * Optional because we store a Node entry after learning about it from
77          * a channel announcement, but before receiving a node announcement.
78          * 
79          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
80          */
81         @Nullable
82         public NodeAnnouncementInfo get_announcement_info() {
83                 long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
84                 Reference.reachabilityFence(this);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
88                 return ret_hu_conv;
89         }
90
91         /**
92          * More information about a node from node_announcement.
93          * Optional because we store a Node entry after learning about it from
94          * a channel announcement, but before receiving a node announcement.
95          * 
96          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
97          */
98         public void set_announcement_info(@Nullable NodeAnnouncementInfo val) {
99                 bindings.NodeInfo_set_announcement_info(this.ptr, val == null ? 0 : val.ptr);
100                 Reference.reachabilityFence(this);
101                 Reference.reachabilityFence(val);
102                 if (this != null) { this.ptrs_to.add(val); };
103         }
104
105         /**
106          * Constructs a new NodeInfo given each field
107          */
108         public static NodeInfo of(long[] channels_arg, RoutingFees lowest_inbound_channel_fees_arg, NodeAnnouncementInfo announcement_info_arg) {
109                 long ret = bindings.NodeInfo_new(channels_arg, lowest_inbound_channel_fees_arg == null ? 0 : lowest_inbound_channel_fees_arg.ptr, announcement_info_arg == null ? 0 : announcement_info_arg.ptr);
110                 Reference.reachabilityFence(channels_arg);
111                 Reference.reachabilityFence(lowest_inbound_channel_fees_arg);
112                 Reference.reachabilityFence(announcement_info_arg);
113                 if (ret >= 0 && ret <= 4096) { return null; }
114                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(lowest_inbound_channel_fees_arg); };
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(announcement_info_arg); };
118                 return ret_hu_conv;
119         }
120
121         long clone_ptr() {
122                 long ret = bindings.NodeInfo_clone_ptr(this.ptr);
123                 Reference.reachabilityFence(this);
124                 return ret;
125         }
126
127         /**
128          * Creates a copy of the NodeInfo
129          */
130         public NodeInfo clone() {
131                 long ret = bindings.NodeInfo_clone(this.ptr);
132                 Reference.reachabilityFence(this);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
135                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
136                 return ret_hu_conv;
137         }
138
139         /**
140          * Checks if two NodeInfos contain equal inner contents.
141          * This ignores pointers and is_owned flags and looks at the values in fields.
142          * Two objects with NULL inner values will be considered "equal" here.
143          */
144         public boolean eq(NodeInfo b) {
145                 boolean ret = bindings.NodeInfo_eq(this.ptr, b == null ? 0 : b.ptr);
146                 Reference.reachabilityFence(this);
147                 Reference.reachabilityFence(b);
148                 if (this != null) { this.ptrs_to.add(b); };
149                 return ret;
150         }
151
152         @Override public boolean equals(Object o) {
153                 if (!(o instanceof NodeInfo)) return false;
154                 return this.eq((NodeInfo)o);
155         }
156         /**
157          * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read
158          */
159         public byte[] write() {
160                 byte[] ret = bindings.NodeInfo_write(this.ptr);
161                 Reference.reachabilityFence(this);
162                 return ret;
163         }
164
165         /**
166          * Read a NodeInfo from a byte array, created by NodeInfo_write
167          */
168         public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
169                 long ret = bindings.NodeInfo_read(ser);
170                 Reference.reachabilityFence(ser);
171                 if (ret >= 0 && ret <= 4096) { return null; }
172                 Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
173                 return ret_hu_conv;
174         }
175
176 }