[Java] Update auto-generated bindings to 0.0.115
[ldk-java] / src / main / java / org / ldk / structs / Hints.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  * Routing hints for the tail of the route.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Hints extends CommonBase {
16         private Hints(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Hints_free(ptr); }
21         }
22         static Hints constr_from_ptr(long ptr) {
23                 bindings.LDKHints raw_val = bindings.LDKHints_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKHints.Blinded.class) {
25                         return new Blinded(ptr, (bindings.LDKHints.Blinded)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKHints.Clear.class) {
28                         return new Clear(ptr, (bindings.LDKHints.Clear)raw_val);
29                 }
30                 assert false; return null; // Unreachable without extending the (internal) bindings interface
31         }
32
33         /**
34          * The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves
35          * will be included in the final [`Route`].
36          */
37         public final static class Blinded extends Hints {
38                 public final TwoTuple_BlindedPayInfoBlindedPathZ[] blinded;
39                 private Blinded(long ptr, bindings.LDKHints.Blinded obj) {
40                         super(null, ptr);
41                         long[] blinded = obj.blinded;
42                         int blinded_conv_37_len = blinded.length;
43                         TwoTuple_BlindedPayInfoBlindedPathZ[] blinded_conv_37_arr = new TwoTuple_BlindedPayInfoBlindedPathZ[blinded_conv_37_len];
44                         for (int l = 0; l < blinded_conv_37_len; l++) {
45                                 long blinded_conv_37 = blinded[l];
46                                 TwoTuple_BlindedPayInfoBlindedPathZ blinded_conv_37_hu_conv = new TwoTuple_BlindedPayInfoBlindedPathZ(null, blinded_conv_37);
47                                 if (blinded_conv_37_hu_conv != null) { blinded_conv_37_hu_conv.ptrs_to.add(this); };
48                                 blinded_conv_37_arr[l] = blinded_conv_37_hu_conv;
49                         }
50                         this.blinded = blinded_conv_37_arr;
51                 }
52         }
53         /**
54          * The recipient included these route hints in their BOLT11 invoice.
55          */
56         public final static class Clear extends Hints {
57                 public final RouteHint[] clear;
58                 private Clear(long ptr, bindings.LDKHints.Clear obj) {
59                         super(null, ptr);
60                         long[] clear = obj.clear;
61                         int clear_conv_11_len = clear.length;
62                         RouteHint[] clear_conv_11_arr = new RouteHint[clear_conv_11_len];
63                         for (int l = 0; l < clear_conv_11_len; l++) {
64                                 long clear_conv_11 = clear[l];
65                                 org.ldk.structs.RouteHint clear_conv_11_hu_conv = null; if (clear_conv_11 < 0 || clear_conv_11 > 4096) { clear_conv_11_hu_conv = new org.ldk.structs.RouteHint(null, clear_conv_11); }
66                                 if (clear_conv_11_hu_conv != null) { clear_conv_11_hu_conv.ptrs_to.add(this); };
67                                 clear_conv_11_arr[l] = clear_conv_11_hu_conv;
68                         }
69                         this.clear = clear_conv_11_arr;
70                 }
71         }
72         long clone_ptr() {
73                 long ret = bindings.Hints_clone_ptr(this.ptr);
74                 Reference.reachabilityFence(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of the Hints
80          */
81         public Hints clone() {
82                 long ret = bindings.Hints_clone(this.ptr);
83                 Reference.reachabilityFence(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.Hints ret_hu_conv = org.ldk.structs.Hints.constr_from_ptr(ret);
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Utility method to constructs a new Blinded-variant Hints
92          */
93         public static Hints blinded(TwoTuple_BlindedPayInfoBlindedPathZ[] a) {
94                 long ret = bindings.Hints_blinded(a != null ? Arrays.stream(a).mapToLong(a_conv_37 -> a_conv_37 != null ? a_conv_37.ptr : 0).toArray() : null);
95                 Reference.reachabilityFence(a);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.Hints ret_hu_conv = org.ldk.structs.Hints.constr_from_ptr(ret);
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Utility method to constructs a new Clear-variant Hints
104          */
105         public static Hints clear(RouteHint[] a) {
106                 long ret = bindings.Hints_clear(a != null ? Arrays.stream(a).mapToLong(a_conv_11 -> a_conv_11 == null ? 0 : a_conv_11.ptr).toArray() : null);
107                 Reference.reachabilityFence(a);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.Hints ret_hu_conv = org.ldk.structs.Hints.constr_from_ptr(ret);
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
111                 for (RouteHint a_conv_11: a) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a_conv_11); }; };
112                 return ret_hu_conv;
113         }
114
115         /**
116          * Generates a non-cryptographic 64-bit hash of the Hints.
117          */
118         public long hash() {
119                 long ret = bindings.Hints_hash(this.ptr);
120                 Reference.reachabilityFence(this);
121                 return ret;
122         }
123
124         @Override public int hashCode() {
125                 return (int)this.hash();
126         }
127         /**
128          * Checks if two Hintss contain equal inner contents.
129          * This ignores pointers and is_owned flags and looks at the values in fields.
130          */
131         public boolean eq(org.ldk.structs.Hints b) {
132                 boolean ret = bindings.Hints_eq(this.ptr, b == null ? 0 : b.ptr);
133                 Reference.reachabilityFence(this);
134                 Reference.reachabilityFence(b);
135                 return ret;
136         }
137
138         @Override public boolean equals(Object o) {
139                 if (!(o instanceof Hints)) return false;
140                 return this.eq((Hints)o);
141         }
142 }