9f3d83912c95a4c792cc1f0d3e072d79158d7073
[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 [`msgs::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          * Constructs a new OnionMessagePath given each field
67          */
68         public static OnionMessagePath of(byte[][] intermediate_nodes_arg, org.ldk.structs.Destination destination_arg) {
69                 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);
70                 Reference.reachabilityFence(intermediate_nodes_arg);
71                 Reference.reachabilityFence(destination_arg);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(destination_arg); };
76                 return ret_hu_conv;
77         }
78
79         long clone_ptr() {
80                 long ret = bindings.OnionMessagePath_clone_ptr(this.ptr);
81                 Reference.reachabilityFence(this);
82                 return ret;
83         }
84
85         /**
86          * Creates a copy of the OnionMessagePath
87          */
88         public OnionMessagePath clone() {
89                 long ret = bindings.OnionMessagePath_clone(this.ptr);
90                 Reference.reachabilityFence(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
94                 return ret_hu_conv;
95         }
96
97 }