Update auto-generated bindings to 0.0.101
[ldk-java] / src / main / java / org / ldk / structs / PaymentSendFailure.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 javax.annotation.Nullable;
8
9
10 /**
11  * If a payment fails to send, it can be in one of several states. This enum is returned as the
12  * Err() type describing which state the payment is in, see the description of individual enum
13  * states for more.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class PaymentSendFailure extends CommonBase {
17         private PaymentSendFailure(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.PaymentSendFailure_free(ptr); }
22         }
23         static PaymentSendFailure constr_from_ptr(long ptr) {
24                 bindings.LDKPaymentSendFailure raw_val = bindings.LDKPaymentSendFailure_ref_from_ptr(ptr);
25                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.ParameterError.class) {
26                         return new ParameterError(ptr, (bindings.LDKPaymentSendFailure.ParameterError)raw_val);
27                 }
28                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.PathParameterError.class) {
29                         return new PathParameterError(ptr, (bindings.LDKPaymentSendFailure.PathParameterError)raw_val);
30                 }
31                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.AllFailedRetrySafe.class) {
32                         return new AllFailedRetrySafe(ptr, (bindings.LDKPaymentSendFailure.AllFailedRetrySafe)raw_val);
33                 }
34                 if (raw_val.getClass() == bindings.LDKPaymentSendFailure.PartialFailure.class) {
35                         return new PartialFailure(ptr, (bindings.LDKPaymentSendFailure.PartialFailure)raw_val);
36                 }
37                 assert false; return null; // Unreachable without extending the (internal) bindings interface
38         }
39
40         public final static class ParameterError extends PaymentSendFailure {
41                 public final APIError parameter_error;
42                 private ParameterError(long ptr, bindings.LDKPaymentSendFailure.ParameterError obj) {
43                         super(null, ptr);
44                         long parameter_error = obj.parameter_error;
45                         APIError parameter_error_hu_conv = APIError.constr_from_ptr(parameter_error);
46                         parameter_error_hu_conv.ptrs_to.add(this);
47                         this.parameter_error = parameter_error_hu_conv;
48                 }
49         }
50         public final static class PathParameterError extends PaymentSendFailure {
51                 public final Result_NoneAPIErrorZ[] path_parameter_error;
52                 private PathParameterError(long ptr, bindings.LDKPaymentSendFailure.PathParameterError obj) {
53                         super(null, ptr);
54                         long[] path_parameter_error = obj.path_parameter_error;
55                         Result_NoneAPIErrorZ[] path_parameter_error_conv_22_arr = new Result_NoneAPIErrorZ[path_parameter_error.length];
56                         for (int w = 0; w < path_parameter_error.length; w++) {
57                                 long path_parameter_error_conv_22 = path_parameter_error[w];
58                                 Result_NoneAPIErrorZ path_parameter_error_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(path_parameter_error_conv_22);
59                                 path_parameter_error_conv_22_arr[w] = path_parameter_error_conv_22_hu_conv;
60                         }
61                         this.path_parameter_error = path_parameter_error_conv_22_arr;
62                 }
63         }
64         public final static class AllFailedRetrySafe extends PaymentSendFailure {
65                 public final APIError[] all_failed_retry_safe;
66                 private AllFailedRetrySafe(long ptr, bindings.LDKPaymentSendFailure.AllFailedRetrySafe obj) {
67                         super(null, ptr);
68                         long[] all_failed_retry_safe = obj.all_failed_retry_safe;
69                         APIError[] all_failed_retry_safe_conv_10_arr = new APIError[all_failed_retry_safe.length];
70                         for (int k = 0; k < all_failed_retry_safe.length; k++) {
71                                 long all_failed_retry_safe_conv_10 = all_failed_retry_safe[k];
72                                 APIError all_failed_retry_safe_conv_10_hu_conv = APIError.constr_from_ptr(all_failed_retry_safe_conv_10);
73                                 all_failed_retry_safe_conv_10_hu_conv.ptrs_to.add(this);
74                                 all_failed_retry_safe_conv_10_arr[k] = all_failed_retry_safe_conv_10_hu_conv;
75                         }
76                         this.all_failed_retry_safe = all_failed_retry_safe_conv_10_arr;
77                 }
78         }
79         public final static class PartialFailure extends PaymentSendFailure {
80                 public final Result_NoneAPIErrorZ[] partial_failure;
81                 private PartialFailure(long ptr, bindings.LDKPaymentSendFailure.PartialFailure obj) {
82                         super(null, ptr);
83                         long[] partial_failure = obj.partial_failure;
84                         Result_NoneAPIErrorZ[] partial_failure_conv_22_arr = new Result_NoneAPIErrorZ[partial_failure.length];
85                         for (int w = 0; w < partial_failure.length; w++) {
86                                 long partial_failure_conv_22 = partial_failure[w];
87                                 Result_NoneAPIErrorZ partial_failure_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(partial_failure_conv_22);
88                                 partial_failure_conv_22_arr[w] = partial_failure_conv_22_hu_conv;
89                         }
90                         this.partial_failure = partial_failure_conv_22_arr;
91                 }
92         }
93         /**
94          * Creates a copy of the PaymentSendFailure
95          */
96         public PaymentSendFailure clone() {
97                 long ret = bindings.PaymentSendFailure_clone(this.ptr);
98                 if (ret < 1024) { return null; }
99                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
100                 ret_hu_conv.ptrs_to.add(this);
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Utility method to constructs a new ParameterError-variant PaymentSendFailure
106          */
107         public static PaymentSendFailure parameter_error(APIError a) {
108                 long ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
109                 if (ret < 1024) { return null; }
110                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
111                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
112                 return ret_hu_conv;
113         }
114
115         /**
116          * Utility method to constructs a new PathParameterError-variant PaymentSendFailure
117          */
118         public static PaymentSendFailure path_parameter_error(Result_NoneAPIErrorZ[] a) {
119                 long ret = bindings.PaymentSendFailure_path_parameter_error(a != null ? Arrays.stream(a).mapToLong(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray() : null);
120                 if (ret < 1024) { return null; }
121                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
122                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
123                 return ret_hu_conv;
124         }
125
126         /**
127          * Utility method to constructs a new AllFailedRetrySafe-variant PaymentSendFailure
128          */
129         public static PaymentSendFailure all_failed_retry_safe(APIError[] a) {
130                 long ret = bindings.PaymentSendFailure_all_failed_retry_safe(a != null ? Arrays.stream(a).mapToLong(a_conv_10 -> a_conv_10.ptr).toArray() : null);
131                 if (ret < 1024) { return null; }
132                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
133                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
134                 return ret_hu_conv;
135         }
136
137         /**
138          * Utility method to constructs a new PartialFailure-variant PaymentSendFailure
139          */
140         public static PaymentSendFailure partial_failure(Result_NoneAPIErrorZ[] a) {
141                 long ret = bindings.PaymentSendFailure_partial_failure(a != null ? Arrays.stream(a).mapToLong(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray() : null);
142                 if (ret < 1024) { return null; }
143                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
144                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
145                 return ret_hu_conv;
146         }
147
148 }