[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / PaymentError.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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An error that may occur when making a payment.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class PaymentError extends CommonBase {
16         private PaymentError(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.PaymentError_free(ptr); }
21         }
22         static PaymentError constr_from_ptr(long ptr) {
23                 bindings.LDKPaymentError raw_val = bindings.LDKPaymentError_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKPaymentError.Invoice.class) {
25                         return new Invoice(ptr, (bindings.LDKPaymentError.Invoice)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKPaymentError.Routing.class) {
28                         return new Routing(ptr, (bindings.LDKPaymentError.Routing)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKPaymentError.Sending.class) {
31                         return new Sending(ptr, (bindings.LDKPaymentError.Sending)raw_val);
32                 }
33                 assert false; return null; // Unreachable without extending the (internal) bindings interface
34         }
35
36         /**
37          * An error resulting from the provided [`Invoice`] or payment hash.
38          */
39         public final static class Invoice extends PaymentError {
40                 public final java.lang.String invoice;
41                 private Invoice(long ptr, bindings.LDKPaymentError.Invoice obj) {
42                         super(null, ptr);
43                         this.invoice = obj.invoice;
44                 }
45         }
46         /**
47          * An error occurring when finding a route.
48          */
49         public final static class Routing extends PaymentError {
50                 public final org.ldk.structs.LightningError routing;
51                 private Routing(long ptr, bindings.LDKPaymentError.Routing obj) {
52                         super(null, ptr);
53                         long routing = obj.routing;
54                         LightningError routing_hu_conv = null; if (routing < 0 || routing > 4096) { routing_hu_conv = new LightningError(null, routing); }
55                         routing_hu_conv.ptrs_to.add(this);
56                         this.routing = routing_hu_conv;
57                 }
58         }
59         /**
60          * An error occurring when sending a payment.
61          */
62         public final static class Sending extends PaymentError {
63                 public final org.ldk.structs.PaymentSendFailure sending;
64                 private Sending(long ptr, bindings.LDKPaymentError.Sending obj) {
65                         super(null, ptr);
66                         long sending = obj.sending;
67                         org.ldk.structs.PaymentSendFailure sending_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(sending);
68                         sending_hu_conv.ptrs_to.add(this);
69                         this.sending = sending_hu_conv;
70                 }
71         }
72         long clone_ptr() {
73                 long ret = bindings.PaymentError_clone_ptr(this.ptr);
74                 Reference.reachabilityFence(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of the PaymentError
80          */
81         public PaymentError clone() {
82                 long ret = bindings.PaymentError_clone(this.ptr);
83                 Reference.reachabilityFence(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
86                 ret_hu_conv.ptrs_to.add(this);
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Utility method to constructs a new Invoice-variant PaymentError
92          */
93         public static PaymentError invoice(java.lang.String a) {
94                 long ret = bindings.PaymentError_invoice(a);
95                 Reference.reachabilityFence(a);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
98                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Utility method to constructs a new Routing-variant PaymentError
104          */
105         public static PaymentError routing(LightningError a) {
106                 long ret = bindings.PaymentError_routing(a == null ? 0 : a.ptr & ~1);
107                 Reference.reachabilityFence(a);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
110                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Utility method to constructs a new Sending-variant PaymentError
116          */
117         public static PaymentError sending(PaymentSendFailure a) {
118                 long ret = bindings.PaymentError_sending(a.ptr);
119                 Reference.reachabilityFence(a);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
122                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
123                 return ret_hu_conv;
124         }
125
126 }