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 * Indicates that we failed to send a payment probe. Further errors may be surfaced later via
13 * [`Event::ProbeFailed`].
15 * [`Event::ProbeFailed`]: crate::events::Event::ProbeFailed
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class ProbeSendFailure extends CommonBase {
19 private ProbeSendFailure(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.ProbeSendFailure_free(ptr); }
25 static ProbeSendFailure constr_from_ptr(long ptr) {
26 bindings.LDKProbeSendFailure raw_val = bindings.LDKProbeSendFailure_ref_from_ptr(ptr);
27 if (raw_val.getClass() == bindings.LDKProbeSendFailure.RouteNotFound.class) {
28 return new RouteNotFound(ptr, (bindings.LDKProbeSendFailure.RouteNotFound)raw_val);
30 if (raw_val.getClass() == bindings.LDKProbeSendFailure.SendingFailed.class) {
31 return new SendingFailed(ptr, (bindings.LDKProbeSendFailure.SendingFailed)raw_val);
33 assert false; return null; // Unreachable without extending the (internal) bindings interface
37 * We were unable to find a route to the destination.
39 public final static class RouteNotFound extends ProbeSendFailure {
40 private RouteNotFound(long ptr, bindings.LDKProbeSendFailure.RouteNotFound obj) {
45 * We failed to send the payment probes.
47 public final static class SendingFailed extends ProbeSendFailure {
48 public final org.ldk.structs.PaymentSendFailure sending_failed;
49 private SendingFailed(long ptr, bindings.LDKProbeSendFailure.SendingFailed obj) {
51 long sending_failed = obj.sending_failed;
52 org.ldk.structs.PaymentSendFailure sending_failed_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(sending_failed);
53 if (sending_failed_hu_conv != null) { sending_failed_hu_conv.ptrs_to.add(this); };
54 this.sending_failed = sending_failed_hu_conv;
58 long ret = bindings.ProbeSendFailure_clone_ptr(this.ptr);
59 Reference.reachabilityFence(this);
64 * Creates a copy of the ProbeSendFailure
66 public ProbeSendFailure clone() {
67 long ret = bindings.ProbeSendFailure_clone(this.ptr);
68 Reference.reachabilityFence(this);
69 if (ret >= 0 && ret <= 4096) { return null; }
70 org.ldk.structs.ProbeSendFailure ret_hu_conv = org.ldk.structs.ProbeSendFailure.constr_from_ptr(ret);
71 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
76 * Utility method to constructs a new RouteNotFound-variant ProbeSendFailure
78 public static ProbeSendFailure route_not_found() {
79 long ret = bindings.ProbeSendFailure_route_not_found();
80 if (ret >= 0 && ret <= 4096) { return null; }
81 org.ldk.structs.ProbeSendFailure ret_hu_conv = org.ldk.structs.ProbeSendFailure.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 SendingFailed-variant ProbeSendFailure
89 public static ProbeSendFailure sending_failed(org.ldk.structs.PaymentSendFailure a) {
90 long ret = bindings.ProbeSendFailure_sending_failed(a.ptr);
91 Reference.reachabilityFence(a);
92 if (ret >= 0 && ret <= 4096) { return null; }
93 org.ldk.structs.ProbeSendFailure ret_hu_conv = org.ldk.structs.ProbeSendFailure.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 ProbeSendFailures 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.ProbeSendFailure b) {
104 boolean ret = bindings.ProbeSendFailure_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 ProbeSendFailure)) return false;
112 return this.eq((ProbeSendFailure)o);