Drop old manual implementations of the `Tx{In,Out}` getters
[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.Sending.class) {
28                         return new Sending(ptr, (bindings.LDKPaymentError.Sending)raw_val);
29                 }
30                 assert false; return null; // Unreachable without extending the (internal) bindings interface
31         }
32
33         /**
34          * An error resulting from the provided [`Bolt11Invoice`] or payment hash.
35          */
36         public final static class Invoice extends PaymentError {
37                 public final java.lang.String invoice;
38                 private Invoice(long ptr, bindings.LDKPaymentError.Invoice obj) {
39                         super(null, ptr);
40                         this.invoice = obj.invoice;
41                 }
42         }
43         /**
44          * An error occurring when sending a payment.
45          */
46         public final static class Sending extends PaymentError {
47                 public final org.ldk.enums.RetryableSendFailure sending;
48                 private Sending(long ptr, bindings.LDKPaymentError.Sending obj) {
49                         super(null, ptr);
50                         this.sending = obj.sending;
51                 }
52         }
53         long clone_ptr() {
54                 long ret = bindings.PaymentError_clone_ptr(this.ptr);
55                 Reference.reachabilityFence(this);
56                 return ret;
57         }
58
59         /**
60          * Creates a copy of the PaymentError
61          */
62         public PaymentError clone() {
63                 long ret = bindings.PaymentError_clone(this.ptr);
64                 Reference.reachabilityFence(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Utility method to constructs a new Invoice-variant PaymentError
73          */
74         public static PaymentError invoice(java.lang.String a) {
75                 long ret = bindings.PaymentError_invoice(a);
76                 Reference.reachabilityFence(a);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
79                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Utility method to constructs a new Sending-variant PaymentError
85          */
86         public static PaymentError sending(org.ldk.enums.RetryableSendFailure a) {
87                 long ret = bindings.PaymentError_sending(a);
88                 Reference.reachabilityFence(a);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Checks if two PaymentErrors contain equal inner contents.
97          * This ignores pointers and is_owned flags and looks at the values in fields.
98          */
99         public boolean eq(org.ldk.structs.PaymentError b) {
100                 boolean ret = bindings.PaymentError_eq(this.ptr, b == null ? 0 : b.ptr);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(b);
103                 return ret;
104         }
105
106         @Override public boolean equals(Object o) {
107                 if (!(o instanceof PaymentError)) return false;
108                 return this.eq((PaymentError)o);
109         }
110 }