[Java] Update auto-generated Java structs
[ldk-java] / src / main / java / org / ldk / structs / Init.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  * An init message to be sent or received from a peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Init extends CommonBase {
16         Init(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Init_free(ptr); }
21         }
22
23         /**
24          * The relevant features which the sender supports
25          */
26         public InitFeatures get_features() {
27                 long ret = bindings.Init_get_features(this.ptr);
28                 Reference.reachabilityFence(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The relevant features which the sender supports
37          */
38         public void set_features(InitFeatures val) {
39                 bindings.Init_set_features(this.ptr, val == null ? 0 : val.ptr);
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42                 if (this != null) { this.ptrs_to.add(val); };
43         }
44
45         /**
46          * The receipient's network address. This adds the option to report a remote IP address
47          * back to a connecting peer using the init message. A node can decide to use that information
48          * to discover a potential update to its public IPv4 address (NAT) and use
49          * that for a node_announcement update message containing the new address.
50          */
51         public Option_NetAddressZ get_remote_network_address() {
52                 long ret = bindings.Init_get_remote_network_address(this.ptr);
53                 Reference.reachabilityFence(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 org.ldk.structs.Option_NetAddressZ ret_hu_conv = org.ldk.structs.Option_NetAddressZ.constr_from_ptr(ret);
56                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
57                 return ret_hu_conv;
58         }
59
60         /**
61          * The receipient's network address. This adds the option to report a remote IP address
62          * back to a connecting peer using the init message. A node can decide to use that information
63          * to discover a potential update to its public IPv4 address (NAT) and use
64          * that for a node_announcement update message containing the new address.
65          */
66         public void set_remote_network_address(Option_NetAddressZ val) {
67                 bindings.Init_set_remote_network_address(this.ptr, val.ptr);
68                 Reference.reachabilityFence(this);
69                 Reference.reachabilityFence(val);
70         }
71
72         /**
73          * Constructs a new Init given each field
74          */
75         public static Init of(InitFeatures features_arg, Option_NetAddressZ remote_network_address_arg) {
76                 long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr, remote_network_address_arg.ptr);
77                 Reference.reachabilityFence(features_arg);
78                 Reference.reachabilityFence(remote_network_address_arg);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
81                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(features_arg); };
83                 return ret_hu_conv;
84         }
85
86         long clone_ptr() {
87                 long ret = bindings.Init_clone_ptr(this.ptr);
88                 Reference.reachabilityFence(this);
89                 return ret;
90         }
91
92         /**
93          * Creates a copy of the Init
94          */
95         public Init clone() {
96                 long ret = bindings.Init_clone(this.ptr);
97                 Reference.reachabilityFence(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Init(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Serialize the Init object into a byte array which can be read by Init_read
106          */
107         public byte[] write() {
108                 byte[] ret = bindings.Init_write(this.ptr);
109                 Reference.reachabilityFence(this);
110                 return ret;
111         }
112
113         /**
114          * Read a Init from a byte array, created by Init_write
115          */
116         public static Result_InitDecodeErrorZ read(byte[] ser) {
117                 long ret = bindings.Init_read(ser);
118                 Reference.reachabilityFence(ser);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
121                 return ret_hu_conv;
122         }
123
124 }