Update auto-generated Java bindings (all functionally equivalent)
[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                         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); }
31                         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 & ~1).toArray() : null);
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * Constructs a new RouteHint given each field
45          */
46         public static RouteHint of(RouteHintHop[] a_arg) {
47                 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);
48                 Reference.reachabilityFence(a_arg);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHint(null, ret); }
51                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
52                 return ret_hu_conv;
53         }
54
55         long clone_ptr() {
56                 long ret = bindings.RouteHint_clone_ptr(this.ptr);
57                 Reference.reachabilityFence(this);
58                 return ret;
59         }
60
61         /**
62          * Creates a copy of the RouteHint
63          */
64         public RouteHint clone() {
65                 long ret = bindings.RouteHint_clone(this.ptr);
66                 Reference.reachabilityFence(this);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHint(null, ret); }
69                 ret_hu_conv.ptrs_to.add(this);
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Checks if two RouteHints contain equal inner contents.
75          */
76         public long hash() {
77                 long ret = bindings.RouteHint_hash(this.ptr);
78                 Reference.reachabilityFence(this);
79                 return ret;
80         }
81
82         @Override public int hashCode() {
83                 return (int)this.hash();
84         }
85         /**
86          * Checks if two RouteHints contain equal inner contents.
87          * This ignores pointers and is_owned flags and looks at the values in fields.
88          * Two objects with NULL inner values will be considered "equal" here.
89          */
90         public boolean eq(RouteHint b) {
91                 boolean ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
92                 Reference.reachabilityFence(this);
93                 Reference.reachabilityFence(b);
94                 this.ptrs_to.add(b);
95                 return ret;
96         }
97
98         @Override public boolean equals(Object o) {
99                 if (!(o instanceof RouteHint)) return false;
100                 return this.eq((RouteHint)o);
101         }
102         /**
103          * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
104          */
105         public byte[] write() {
106                 byte[] ret = bindings.RouteHint_write(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
112          * Read a RouteHint from a byte array, created by RouteHint_write
113          */
114         public static Result_RouteHintDecodeErrorZ read(byte[] ser) {
115                 long ret = bindings.RouteHint_read(ser);
116                 Reference.reachabilityFence(ser);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
119                 return ret_hu_conv;
120         }
121
122 }