[Java] Update auto-generated Java bindings
[ldk-java] / src / main / java / org / ldk / structs / RouteParameters.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  * Parameters needed to find a [`Route`].
13  * 
14  * Passed to [`find_route`] and [`build_route_from_hops`], but also provided in
15  * [`Event::PaymentPathFailed`].
16  * 
17  * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
18  */
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class RouteParameters extends CommonBase {
21         RouteParameters(Object _dummy, long ptr) { super(ptr); }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 super.finalize();
25                 if (ptr != 0) { bindings.RouteParameters_free(ptr); }
26         }
27
28         /**
29          * The parameters of the failed payment path.
30          */
31         public PaymentParameters get_payment_params() {
32                 long ret = bindings.RouteParameters_get_payment_params(this.ptr);
33                 Reference.reachabilityFence(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.PaymentParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentParameters(null, ret); }
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * The parameters of the failed payment path.
42          */
43         public void set_payment_params(org.ldk.structs.PaymentParameters val) {
44                 bindings.RouteParameters_set_payment_params(this.ptr, val == null ? 0 : val.ptr);
45                 Reference.reachabilityFence(this);
46                 Reference.reachabilityFence(val);
47                 if (this != null) { this.ptrs_to.add(val); };
48         }
49
50         /**
51          * The amount in msats sent on the failed payment path.
52          */
53         public long get_final_value_msat() {
54                 long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
55                 Reference.reachabilityFence(this);
56                 return ret;
57         }
58
59         /**
60          * The amount in msats sent on the failed payment path.
61          */
62         public void set_final_value_msat(long val) {
63                 bindings.RouteParameters_set_final_value_msat(this.ptr, val);
64                 Reference.reachabilityFence(this);
65                 Reference.reachabilityFence(val);
66         }
67
68         /**
69          * Constructs a new RouteParameters given each field
70          */
71         public static RouteParameters of(org.ldk.structs.PaymentParameters payment_params_arg, long final_value_msat_arg) {
72                 long ret = bindings.RouteParameters_new(payment_params_arg == null ? 0 : payment_params_arg.ptr, final_value_msat_arg);
73                 Reference.reachabilityFence(payment_params_arg);
74                 Reference.reachabilityFence(final_value_msat_arg);
75                 if (ret >= 0 && ret <= 4096) { return null; }
76                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
77                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
78                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_params_arg); };
79                 return ret_hu_conv;
80         }
81
82         long clone_ptr() {
83                 long ret = bindings.RouteParameters_clone_ptr(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * Creates a copy of the RouteParameters
90          */
91         public RouteParameters clone() {
92                 long ret = bindings.RouteParameters_clone(this.ptr);
93                 Reference.reachabilityFence(this);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 org.ldk.structs.RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteParameters(null, ret); }
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
97                 return ret_hu_conv;
98         }
99
100         /**
101          * Checks if two RouteParameterss contain equal inner contents.
102          * This ignores pointers and is_owned flags and looks at the values in fields.
103          * Two objects with NULL inner values will be considered "equal" here.
104          */
105         public boolean eq(org.ldk.structs.RouteParameters b) {
106                 boolean ret = bindings.RouteParameters_eq(this.ptr, b == null ? 0 : b.ptr);
107                 Reference.reachabilityFence(this);
108                 Reference.reachabilityFence(b);
109                 if (this != null) { this.ptrs_to.add(b); };
110                 return ret;
111         }
112
113         @Override public boolean equals(Object o) {
114                 if (!(o instanceof RouteParameters)) return false;
115                 return this.eq((RouteParameters)o);
116         }
117         /**
118          * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
119          */
120         public byte[] write() {
121                 byte[] ret = bindings.RouteParameters_write(this.ptr);
122                 Reference.reachabilityFence(this);
123                 return ret;
124         }
125
126         /**
127          * Read a RouteParameters from a byte array, created by RouteParameters_write
128          */
129         public static Result_RouteParametersDecodeErrorZ read(byte[] ser) {
130                 long ret = bindings.RouteParameters_read(ser);
131                 Reference.reachabilityFence(ser);
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
134                 return ret_hu_conv;
135         }
136
137 }