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 * Private routing information
15 * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class PrivateRoute extends CommonBase {
19 PrivateRoute(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.PrivateRoute_free(ptr); }
27 long ret = bindings.PrivateRoute_clone_ptr(this.ptr);
28 Reference.reachabilityFence(this);
33 * Creates a copy of the PrivateRoute
35 public PrivateRoute clone() {
36 long ret = bindings.PrivateRoute_clone(this.ptr);
37 Reference.reachabilityFence(this);
38 if (ret >= 0 && ret <= 4096) { return null; }
39 org.ldk.structs.PrivateRoute ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrivateRoute(null, ret); }
40 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
45 * Generates a non-cryptographic 64-bit hash of the PrivateRoute.
48 long ret = bindings.PrivateRoute_hash(this.ptr);
49 Reference.reachabilityFence(this);
53 @Override public int hashCode() {
54 return (int)this.hash();
57 * Checks if two PrivateRoutes contain equal inner contents.
58 * This ignores pointers and is_owned flags and looks at the values in fields.
59 * Two objects with NULL inner values will be considered "equal" here.
61 public boolean eq(org.ldk.structs.PrivateRoute b) {
62 boolean ret = bindings.PrivateRoute_eq(this.ptr, b == null ? 0 : b.ptr);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(b);
65 if (this != null) { this.ptrs_to.add(b); };
69 @Override public boolean equals(Object o) {
70 if (!(o instanceof PrivateRoute)) return false;
71 return this.eq((PrivateRoute)o);
74 * Creates a new (partial) route from a list of hops
76 public static Result_PrivateRouteCreationErrorZ of(org.ldk.structs.RouteHint hops) {
77 long ret = bindings.PrivateRoute_new(hops == null ? 0 : hops.ptr);
78 Reference.reachabilityFence(hops);
79 if (ret >= 0 && ret <= 4096) { return null; }
80 Result_PrivateRouteCreationErrorZ ret_hu_conv = Result_PrivateRouteCreationErrorZ.constr_from_ptr(ret);
81 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(hops); };
86 * Returns the underlying list of hops
88 public RouteHint into_inner() {
89 long ret = bindings.PrivateRoute_into_inner(this.ptr);
90 Reference.reachabilityFence(this);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
94 if (this != null) { this.ptrs_to.add(this); };