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 * An error that may occur when sending a payment probe.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ProbingError extends CommonBase {
16 private ProbingError(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ProbingError_free(ptr); }
22 static ProbingError constr_from_ptr(long ptr) {
23 bindings.LDKProbingError raw_val = bindings.LDKProbingError_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKProbingError.Invoice.class) {
25 return new Invoice(ptr, (bindings.LDKProbingError.Invoice)raw_val);
27 if (raw_val.getClass() == bindings.LDKProbingError.Sending.class) {
28 return new Sending(ptr, (bindings.LDKProbingError.Sending)raw_val);
30 assert false; return null; // Unreachable without extending the (internal) bindings interface
34 * An error resulting from the provided [`Bolt11Invoice`].
36 public final static class Invoice extends ProbingError {
37 public final java.lang.String invoice;
38 private Invoice(long ptr, bindings.LDKProbingError.Invoice obj) {
40 this.invoice = obj.invoice;
44 * An error occurring when sending a payment probe.
46 public final static class Sending extends ProbingError {
47 public final org.ldk.structs.ProbeSendFailure sending;
48 private Sending(long ptr, bindings.LDKProbingError.Sending obj) {
50 long sending = obj.sending;
51 org.ldk.structs.ProbeSendFailure sending_hu_conv = org.ldk.structs.ProbeSendFailure.constr_from_ptr(sending);
52 if (sending_hu_conv != null) { sending_hu_conv.ptrs_to.add(this); };
53 this.sending = sending_hu_conv;
57 long ret = bindings.ProbingError_clone_ptr(this.ptr);
58 Reference.reachabilityFence(this);
63 * Creates a copy of the ProbingError
65 public ProbingError clone() {
66 long ret = bindings.ProbingError_clone(this.ptr);
67 Reference.reachabilityFence(this);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 org.ldk.structs.ProbingError ret_hu_conv = org.ldk.structs.ProbingError.constr_from_ptr(ret);
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
75 * Utility method to constructs a new Invoice-variant ProbingError
77 public static ProbingError invoice(java.lang.String a) {
78 long ret = bindings.ProbingError_invoice(a);
79 Reference.reachabilityFence(a);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 org.ldk.structs.ProbingError ret_hu_conv = org.ldk.structs.ProbingError.constr_from_ptr(ret);
82 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
87 * Utility method to constructs a new Sending-variant ProbingError
89 public static ProbingError sending(org.ldk.structs.ProbeSendFailure a) {
90 long ret = bindings.ProbingError_sending(a.ptr);
91 Reference.reachabilityFence(a);
92 if (ret >= 0 && ret <= 4096) { return null; }
93 org.ldk.structs.ProbingError ret_hu_conv = org.ldk.structs.ProbingError.constr_from_ptr(ret);
94 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
95 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
100 * Checks if two ProbingErrors contain equal inner contents.
101 * This ignores pointers and is_owned flags and looks at the values in fields.
103 public boolean eq(org.ldk.structs.ProbingError b) {
104 boolean ret = bindings.ProbingError_eq(this.ptr, b == null ? 0 : b.ptr);
105 Reference.reachabilityFence(this);
106 Reference.reachabilityFence(b);
110 @Override public boolean equals(Object o) {
111 if (!(o instanceof ProbingError)) return false;
112 return this.eq((ProbingError)o);