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