1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * If a payment fails to send, it can be in one of several states. This enum is returned as the
11 * Err() type describing which state the payment is in, see the description of individual enum
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class PaymentSendFailure extends CommonBase {
16 private PaymentSendFailure(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.PaymentSendFailure_free(ptr); }
22 static PaymentSendFailure constr_from_ptr(long ptr) {
23 bindings.LDKPaymentSendFailure raw_val = bindings.LDKPaymentSendFailure_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.ParameterError.class) {
25 return new ParameterError(ptr, (bindings.LDKPaymentSendFailure.ParameterError)raw_val);
27 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.PathParameterError.class) {
28 return new PathParameterError(ptr, (bindings.LDKPaymentSendFailure.PathParameterError)raw_val);
30 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.AllFailedRetrySafe.class) {
31 return new AllFailedRetrySafe(ptr, (bindings.LDKPaymentSendFailure.AllFailedRetrySafe)raw_val);
33 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.PartialFailure.class) {
34 return new PartialFailure(ptr, (bindings.LDKPaymentSendFailure.PartialFailure)raw_val);
36 assert false; return null; // Unreachable without extending the (internal) bindings interface
39 public final static class ParameterError extends PaymentSendFailure {
40 public final APIError parameter_error;
41 private ParameterError(long ptr, bindings.LDKPaymentSendFailure.ParameterError obj) {
43 long parameter_error = obj.parameter_error;
44 APIError parameter_error_hu_conv = APIError.constr_from_ptr(parameter_error);
45 parameter_error_hu_conv.ptrs_to.add(this);
46 this.parameter_error = parameter_error_hu_conv;
49 public final static class PathParameterError extends PaymentSendFailure {
50 public final Result_NoneAPIErrorZ[] path_parameter_error;
51 private PathParameterError(long ptr, bindings.LDKPaymentSendFailure.PathParameterError obj) {
53 long[] path_parameter_error = obj.path_parameter_error;
54 Result_NoneAPIErrorZ[] path_parameter_error_conv_22_arr = new Result_NoneAPIErrorZ[path_parameter_error.length];
55 for (int w = 0; w < path_parameter_error.length; w++) {
56 long path_parameter_error_conv_22 = path_parameter_error[w];
57 Result_NoneAPIErrorZ path_parameter_error_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(path_parameter_error_conv_22);
58 path_parameter_error_conv_22_arr[w] = path_parameter_error_conv_22_hu_conv;
60 this.path_parameter_error = path_parameter_error_conv_22_arr;
63 public final static class AllFailedRetrySafe extends PaymentSendFailure {
64 public final APIError[] all_failed_retry_safe;
65 private AllFailedRetrySafe(long ptr, bindings.LDKPaymentSendFailure.AllFailedRetrySafe obj) {
67 long[] all_failed_retry_safe = obj.all_failed_retry_safe;
68 APIError[] all_failed_retry_safe_conv_10_arr = new APIError[all_failed_retry_safe.length];
69 for (int k = 0; k < all_failed_retry_safe.length; k++) {
70 long all_failed_retry_safe_conv_10 = all_failed_retry_safe[k];
71 APIError all_failed_retry_safe_conv_10_hu_conv = APIError.constr_from_ptr(all_failed_retry_safe_conv_10);
72 all_failed_retry_safe_conv_10_hu_conv.ptrs_to.add(this);
73 all_failed_retry_safe_conv_10_arr[k] = all_failed_retry_safe_conv_10_hu_conv;
75 this.all_failed_retry_safe = all_failed_retry_safe_conv_10_arr;
78 public final static class PartialFailure extends PaymentSendFailure {
79 public final Result_NoneAPIErrorZ[] partial_failure;
80 private PartialFailure(long ptr, bindings.LDKPaymentSendFailure.PartialFailure obj) {
82 long[] partial_failure = obj.partial_failure;
83 Result_NoneAPIErrorZ[] partial_failure_conv_22_arr = new Result_NoneAPIErrorZ[partial_failure.length];
84 for (int w = 0; w < partial_failure.length; w++) {
85 long partial_failure_conv_22 = partial_failure[w];
86 Result_NoneAPIErrorZ partial_failure_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(partial_failure_conv_22);
87 partial_failure_conv_22_arr[w] = partial_failure_conv_22_hu_conv;
89 this.partial_failure = partial_failure_conv_22_arr;
93 * Creates a copy of the PaymentSendFailure
95 public PaymentSendFailure clone() {
96 long ret = bindings.PaymentSendFailure_clone(this.ptr);
97 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
98 ret_hu_conv.ptrs_to.add(this);