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