1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * A list of hops along a payment path terminating with a channel to the recipient.
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 {
19 if (ptr != 0) { bindings.RouteHint_free(ptr); }
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;
31 return ret_conv_14_arr;
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);
39 * Constructs a new RouteHint given each field
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);
50 * Creates a copy of the RouteHint
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);
61 * Checks if two RouteHints contain equal inner contents.
64 long ret = bindings.RouteHint_hash(this.ptr);
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.
73 public boolean eq(RouteHint b) {
74 boolean ret = bindings.RouteHint_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
80 * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
82 public byte[] write() {
83 byte[] ret = bindings.RouteHint_write(this.ptr);
88 * Read a RouteHint from a byte array, created by RouteHint_write
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);