[Java] Update auto-generated Java bindings for 0.0.113
[ldk-java] / src / main / java / org / ldk / structs / RouteHint.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 list of hops along a payment path terminating with a channel to the recipient.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class RouteHint extends CommonBase {
16         RouteHint(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.RouteHint_free(ptr); }
21         }
22
23         public RouteHintHop[] get_a() {
24                 long[] ret = bindings.RouteHint_get_a(this.ptr);
25                 Reference.reachabilityFence(this);
26                 int ret_conv_14_len = ret.length;
27                 RouteHintHop[] ret_conv_14_arr = new RouteHintHop[ret_conv_14_len];
28                 for (int o = 0; o < ret_conv_14_len; o++) {
29                         long ret_conv_14 = ret[o];
30                         org.ldk.structs.RouteHintHop ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new org.ldk.structs.RouteHintHop(null, ret_conv_14); }
31                         if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.add(this); };
32                         ret_conv_14_arr[o] = ret_conv_14_hu_conv;
33                 }
34                 return ret_conv_14_arr;
35         }
36
37         public void set_a(RouteHintHop[] val) {
38                 bindings.RouteHint_set_a(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_14 -> val_conv_14 == null ? 0 : val_conv_14.ptr).toArray() : null);
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41                 for (RouteHintHop val_conv_14: val) { if (this != null) { this.ptrs_to.add(val_conv_14); }; };
42         }
43
44         /**
45          * Constructs a new RouteHint given each field
46          */
47         public static RouteHint of(RouteHintHop[] a_arg) {
48                 long ret = bindings.RouteHint_new(a_arg != null ? Arrays.stream(a_arg).mapToLong(a_arg_conv_14 -> a_arg_conv_14 == null ? 0 : a_arg_conv_14.ptr).toArray() : null);
49                 Reference.reachabilityFence(a_arg);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
52                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
53                 for (RouteHintHop a_arg_conv_14: a_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a_arg_conv_14); }; };
54                 return ret_hu_conv;
55         }
56
57         long clone_ptr() {
58                 long ret = bindings.RouteHint_clone_ptr(this.ptr);
59                 Reference.reachabilityFence(this);
60                 return ret;
61         }
62
63         /**
64          * Creates a copy of the RouteHint
65          */
66         public RouteHint clone() {
67                 long ret = bindings.RouteHint_clone(this.ptr);
68                 Reference.reachabilityFence(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
72                 return ret_hu_conv;
73         }
74
75         /**
76          * Checks if two RouteHints contain equal inner contents.
77          */
78         public long hash() {
79                 long ret = bindings.RouteHint_hash(this.ptr);
80                 Reference.reachabilityFence(this);
81                 return ret;
82         }
83
84         @Override public int hashCode() {
85                 return (int)this.hash();
86         }
87         /**
88          * Checks if two RouteHints contain equal inner contents.
89          * This ignores pointers and is_owned flags and looks at the values in fields.
90          * Two objects with NULL inner values will be considered "equal" here.
91          */
92         public boolean eq(org.ldk.structs.RouteHint b) {
93                 boolean ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr);
94                 Reference.reachabilityFence(this);
95                 Reference.reachabilityFence(b);
96                 if (this != null) { this.ptrs_to.add(b); };
97                 return ret;
98         }
99
100         @Override public boolean equals(Object o) {
101                 if (!(o instanceof RouteHint)) return false;
102                 return this.eq((RouteHint)o);
103         }
104         /**
105          * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
106          */
107         public byte[] write() {
108                 byte[] ret = bindings.RouteHint_write(this.ptr);
109                 Reference.reachabilityFence(this);
110                 return ret;
111         }
112
113         /**
114          * Read a RouteHint from a byte array, created by RouteHint_write
115          */
116         public static Result_RouteHintDecodeErrorZ read(byte[] ser) {
117                 long ret = bindings.RouteHint_read(ser);
118                 Reference.reachabilityFence(ser);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
121                 return ret_hu_conv;
122         }
123
124 }