[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / OnionMessagePath.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  * A path for sending an [`OnionMessage`].
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class OnionMessagePath extends CommonBase {
16         OnionMessagePath(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.OnionMessagePath_free(ptr); }
21         }
22
23         /**
24          * Nodes on the path between the sender and the destination.
25          * 
26          * Returns a copy of the field.
27          */
28         public byte[][] get_intermediate_nodes() {
29                 byte[][] ret = bindings.OnionMessagePath_get_intermediate_nodes(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * Nodes on the path between the sender and the destination.
36          */
37         public void set_intermediate_nodes(byte[][] val) {
38                 bindings.OnionMessagePath_set_intermediate_nodes(this.ptr, val != null ? Arrays.stream(val).map(val_conv_8 -> InternalUtils.check_arr_len(val_conv_8, 33)).toArray(byte[][]::new) : null);
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The recipient of the message.
45          */
46         public Destination get_destination() {
47                 long ret = bindings.OnionMessagePath_get_destination(this.ptr);
48                 Reference.reachabilityFence(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * The recipient of the message.
57          */
58         public void set_destination(org.ldk.structs.Destination val) {
59                 bindings.OnionMessagePath_set_destination(this.ptr, val.ptr);
60                 Reference.reachabilityFence(this);
61                 Reference.reachabilityFence(val);
62                 if (this != null) { this.ptrs_to.add(val); };
63         }
64
65         /**
66          * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
67          * 
68          * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
69          * this to initiate such a connection.
70          * 
71          * Returns a copy of the field.
72          */
73         public Option_CVec_SocketAddressZZ get_first_node_addresses() {
74                 long ret = bindings.OnionMessagePath_get_first_node_addresses(this.ptr);
75                 Reference.reachabilityFence(this);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 org.ldk.structs.Option_CVec_SocketAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_SocketAddressZZ.constr_from_ptr(ret);
78                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
79                 return ret_hu_conv;
80         }
81
82         /**
83          * Addresses that may be used to connect to [`OnionMessagePath::first_node`].
84          * 
85          * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
86          * this to initiate such a connection.
87          */
88         public void set_first_node_addresses(org.ldk.structs.Option_CVec_SocketAddressZZ val) {
89                 bindings.OnionMessagePath_set_first_node_addresses(this.ptr, val.ptr);
90                 Reference.reachabilityFence(this);
91                 Reference.reachabilityFence(val);
92                 if (this != null) { this.ptrs_to.add(val); };
93         }
94
95         /**
96          * Constructs a new OnionMessagePath given each field
97          */
98         public static OnionMessagePath of(byte[][] intermediate_nodes_arg, org.ldk.structs.Destination destination_arg, org.ldk.structs.Option_CVec_SocketAddressZZ first_node_addresses_arg) {
99                 long ret = bindings.OnionMessagePath_new(intermediate_nodes_arg != null ? Arrays.stream(intermediate_nodes_arg).map(intermediate_nodes_arg_conv_8 -> InternalUtils.check_arr_len(intermediate_nodes_arg_conv_8, 33)).toArray(byte[][]::new) : null, destination_arg.ptr, first_node_addresses_arg.ptr);
100                 Reference.reachabilityFence(intermediate_nodes_arg);
101                 Reference.reachabilityFence(destination_arg);
102                 Reference.reachabilityFence(first_node_addresses_arg);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(destination_arg); };
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(first_node_addresses_arg); };
108                 return ret_hu_conv;
109         }
110
111         long clone_ptr() {
112                 long ret = bindings.OnionMessagePath_clone_ptr(this.ptr);
113                 Reference.reachabilityFence(this);
114                 return ret;
115         }
116
117         /**
118          * Creates a copy of the OnionMessagePath
119          */
120         public OnionMessagePath clone() {
121                 long ret = bindings.OnionMessagePath_clone(this.ptr);
122                 Reference.reachabilityFence(this);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Returns the first node in the path.
131          */
132         public byte[] first_node() {
133                 byte[] ret = bindings.OnionMessagePath_first_node(this.ptr);
134                 Reference.reachabilityFence(this);
135                 return ret;
136         }
137
138 }