1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A list of hops along a payment path terminating with a channel to the recipient.
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 {
20 if (ptr != 0) { bindings.RouteHint_free(ptr); }
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 ret_conv_14_hu_conv.ptrs_to.add(this);
32 ret_conv_14_arr[o] = ret_conv_14_hu_conv;
34 return ret_conv_14_arr;
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);
44 * Constructs a new RouteHint given each field
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 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
51 ret_hu_conv.ptrs_to.add(ret_hu_conv);
56 long ret = bindings.RouteHint_clone_ptr(this.ptr);
57 Reference.reachabilityFence(this);
62 * Creates a copy of the RouteHint
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 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
69 ret_hu_conv.ptrs_to.add(this);
74 * Checks if two RouteHints contain equal inner contents.
77 long ret = bindings.RouteHint_hash(this.ptr);
78 Reference.reachabilityFence(this);
82 @Override public int hashCode() {
83 return (int)this.hash();
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.
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);
98 @Override public boolean equals(Object o) {
99 if (!(o instanceof RouteHint)) return false;
100 return this.eq((RouteHint)o);
103 * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
105 public byte[] write() {
106 byte[] ret = bindings.RouteHint_write(this.ptr);
107 Reference.reachabilityFence(this);
112 * Read a RouteHint from a byte array, created by RouteHint_write
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);