Update auto-generated bindings to 0.0.103
[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                 /**
81                  * The errors themselves, in the same order as the route hops.
82                 */
83                 public final Result_NoneAPIErrorZ[] results;
84                 /**
85                  * If some paths failed without irrevocably committing to the new HTLC(s), this will
86                  * contain a [`RouteParameters`] object which can be used to calculate a new route that
87                  * will pay all remaining unpaid balance.
88                  * 
89                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
90                 */
91                 @Nullable public final RouteParameters failed_paths_retry;
92                 /**
93                  * The payment id for the payment, which is now at least partially pending.
94                 */
95                 public final byte[] payment_id;
96                 private PartialFailure(long ptr, bindings.LDKPaymentSendFailure.PartialFailure obj) {
97                         super(null, ptr);
98                         long[] results = obj.results;
99                         Result_NoneAPIErrorZ[] results_conv_22_arr = new Result_NoneAPIErrorZ[results.length];
100                         for (int w = 0; w < results.length; w++) {
101                                 long results_conv_22 = results[w];
102                                 Result_NoneAPIErrorZ results_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(results_conv_22);
103                                 results_conv_22_arr[w] = results_conv_22_hu_conv;
104                         }
105                         this.results = results_conv_22_arr;
106                         long failed_paths_retry = obj.failed_paths_retry;
107                         RouteParameters failed_paths_retry_hu_conv = null; if (failed_paths_retry < 0 || failed_paths_retry > 4096) { failed_paths_retry_hu_conv = new RouteParameters(null, failed_paths_retry); }
108                         failed_paths_retry_hu_conv.ptrs_to.add(this);
109                         this.failed_paths_retry = failed_paths_retry_hu_conv;
110                         this.payment_id = obj.payment_id;
111                 }
112         }
113         /**
114          * Creates a copy of the PaymentSendFailure
115          */
116         public PaymentSendFailure clone() {
117                 long ret = bindings.PaymentSendFailure_clone(this.ptr);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
120                 ret_hu_conv.ptrs_to.add(this);
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Utility method to constructs a new ParameterError-variant PaymentSendFailure
126          */
127         public static PaymentSendFailure parameter_error(APIError a) {
128                 long ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
131                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Utility method to constructs a new PathParameterError-variant PaymentSendFailure
137          */
138         public static PaymentSendFailure path_parameter_error(Result_NoneAPIErrorZ[] a) {
139                 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);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
142                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
143                 return ret_hu_conv;
144         }
145
146         /**
147          * Utility method to constructs a new AllFailedRetrySafe-variant PaymentSendFailure
148          */
149         public static PaymentSendFailure all_failed_retry_safe(APIError[] a) {
150                 long ret = bindings.PaymentSendFailure_all_failed_retry_safe(a != null ? Arrays.stream(a).mapToLong(a_conv_10 -> a_conv_10.ptr).toArray() : null);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
153                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
154                 return ret_hu_conv;
155         }
156
157         /**
158          * Utility method to constructs a new PartialFailure-variant PaymentSendFailure
159          */
160         public static PaymentSendFailure partial_failure(Result_NoneAPIErrorZ[] results, RouteParameters failed_paths_retry, byte[] payment_id) {
161                 long ret = bindings.PaymentSendFailure_partial_failure(results != null ? Arrays.stream(results).mapToLong(results_conv_22 -> results_conv_22 != null ? results_conv_22.ptr : 0).toArray() : null, failed_paths_retry == null ? 0 : failed_paths_retry.ptr & ~1, payment_id);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
164                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
165                 return ret_hu_conv;
166         }
167
168 }