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 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;
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).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); }; };
45 * Constructs a new RouteHint given each field
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); }; };
58 long ret = bindings.RouteHint_clone_ptr(this.ptr);
59 Reference.reachabilityFence(this);
64 * Creates a copy of the RouteHint
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); };
76 * Checks if two RouteHints contain equal inner contents.
79 long ret = bindings.RouteHint_hash(this.ptr);
80 Reference.reachabilityFence(this);
84 @Override public int hashCode() {
85 return (int)this.hash();
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.
92 public boolean eq(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); };
100 @Override public boolean equals(Object o) {
101 if (!(o instanceof RouteHint)) return false;
102 return this.eq((RouteHint)o);
105 * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
107 public byte[] write() {
108 byte[] ret = bindings.RouteHint_write(this.ptr);
109 Reference.reachabilityFence(this);
114 * Read a RouteHint from a byte array, created by RouteHint_write
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);