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