[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / Retry.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  * Strategies available to retry payment path failures.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Retry extends CommonBase {
16         private Retry(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Retry_free(ptr); }
21         }
22         static Retry constr_from_ptr(long ptr) {
23                 bindings.LDKRetry raw_val = bindings.LDKRetry_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKRetry.Attempts.class) {
25                         return new Attempts(ptr, (bindings.LDKRetry.Attempts)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKRetry.Timeout.class) {
28                         return new Timeout(ptr, (bindings.LDKRetry.Timeout)raw_val);
29                 }
30                 assert false; return null; // Unreachable without extending the (internal) bindings interface
31         }
32
33         /**
34          * Max number of attempts to retry payment.
35          * 
36          * Each attempt may be multiple HTLCs along multiple paths if the router decides to split up a
37          * retry, and may retry multiple failed HTLCs at once if they failed around the same time and
38          * were retried along a route from a single call to [`Router::find_route_with_id`].
39          */
40         public final static class Attempts extends Retry {
41                 public final int attempts;
42                 private Attempts(long ptr, bindings.LDKRetry.Attempts obj) {
43                         super(null, ptr);
44                         this.attempts = obj.attempts;
45                 }
46         }
47         /**
48          * Time elapsed before abandoning retries for a payment. At least one attempt at payment is made;
49          * see [`PaymentParameters::expiry_time`] to avoid any attempt at payment after a specific time.
50          * 
51          * [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
52          */
53         public final static class Timeout extends Retry {
54                 public final long timeout;
55                 private Timeout(long ptr, bindings.LDKRetry.Timeout obj) {
56                         super(null, ptr);
57                         this.timeout = obj.timeout;
58                 }
59         }
60         long clone_ptr() {
61                 long ret = bindings.Retry_clone_ptr(this.ptr);
62                 Reference.reachabilityFence(this);
63                 return ret;
64         }
65
66         /**
67          * Creates a copy of the Retry
68          */
69         public Retry clone() {
70                 long ret = bindings.Retry_clone(this.ptr);
71                 Reference.reachabilityFence(this);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.Retry ret_hu_conv = org.ldk.structs.Retry.constr_from_ptr(ret);
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Utility method to constructs a new Attempts-variant Retry
80          */
81         public static Retry attempts(int a) {
82                 long ret = bindings.Retry_attempts(a);
83                 Reference.reachabilityFence(a);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.Retry ret_hu_conv = org.ldk.structs.Retry.constr_from_ptr(ret);
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Utility method to constructs a new Timeout-variant Retry
92          */
93         public static Retry timeout(long a) {
94                 long ret = bindings.Retry_timeout(a);
95                 Reference.reachabilityFence(a);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.Retry ret_hu_conv = org.ldk.structs.Retry.constr_from_ptr(ret);
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Checks if two Retrys contain equal inner contents.
104          * This ignores pointers and is_owned flags and looks at the values in fields.
105          */
106         public boolean eq(org.ldk.structs.Retry b) {
107                 boolean ret = bindings.Retry_eq(this.ptr, b == null ? 0 : b.ptr);
108                 Reference.reachabilityFence(this);
109                 Reference.reachabilityFence(b);
110                 return ret;
111         }
112
113         @Override public boolean equals(Object o) {
114                 if (!(o instanceof Retry)) return false;
115                 return this.eq((Retry)o);
116         }
117         /**
118          * Generates a non-cryptographic 64-bit hash of the Retry.
119          */
120         public long hash() {
121                 long ret = bindings.Retry_hash(this.ptr);
122                 Reference.reachabilityFence(this);
123                 return ret;
124         }
125
126         @Override public int hashCode() {
127                 return (int)this.hash();
128         }
129         /**
130          * Serialize the Retry object into a byte array which can be read by Retry_read
131          */
132         public byte[] write() {
133                 byte[] ret = bindings.Retry_write(this.ptr);
134                 Reference.reachabilityFence(this);
135                 return ret;
136         }
137
138         /**
139          * Read a Retry from a byte array, created by Retry_write
140          */
141         public static Result_RetryDecodeErrorZ read(byte[] ser) {
142                 long ret = bindings.Retry_read(ser);
143                 Reference.reachabilityFence(ser);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 Result_RetryDecodeErrorZ ret_hu_conv = Result_RetryDecodeErrorZ.constr_from_ptr(ret);
146                 return ret_hu_conv;
147         }
148
149 }