[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / OfferId.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 identifier for an [`Offer`] built using [`DerivedMetadata`].
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class OfferId extends CommonBase {
16         OfferId(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.OfferId_free(ptr); }
21         }
22
23         public byte[] get_a() {
24                 byte[] ret = bindings.OfferId_get_a(this.ptr);
25                 Reference.reachabilityFence(this);
26                 return ret;
27         }
28
29         public void set_a(byte[] val) {
30                 bindings.OfferId_set_a(this.ptr, InternalUtils.check_arr_len(val, 32));
31                 Reference.reachabilityFence(this);
32                 Reference.reachabilityFence(val);
33         }
34
35         /**
36          * Constructs a new OfferId given each field
37          */
38         public static OfferId of(byte[] a_arg) {
39                 long ret = bindings.OfferId_new(InternalUtils.check_arr_len(a_arg, 32));
40                 Reference.reachabilityFence(a_arg);
41                 if (ret >= 0 && ret <= 4096) { return null; }
42                 org.ldk.structs.OfferId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferId(null, ret); }
43                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
44                 return ret_hu_conv;
45         }
46
47         long clone_ptr() {
48                 long ret = bindings.OfferId_clone_ptr(this.ptr);
49                 Reference.reachabilityFence(this);
50                 return ret;
51         }
52
53         /**
54          * Creates a copy of the OfferId
55          */
56         public OfferId clone() {
57                 long ret = bindings.OfferId_clone(this.ptr);
58                 Reference.reachabilityFence(this);
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 org.ldk.structs.OfferId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferId(null, ret); }
61                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
62                 return ret_hu_conv;
63         }
64
65         /**
66          * Checks if two OfferIds contain equal inner contents.
67          * This ignores pointers and is_owned flags and looks at the values in fields.
68          * Two objects with NULL inner values will be considered "equal" here.
69          */
70         public boolean eq(org.ldk.structs.OfferId b) {
71                 boolean ret = bindings.OfferId_eq(this.ptr, b.ptr);
72                 Reference.reachabilityFence(this);
73                 Reference.reachabilityFence(b);
74                 if (this != null) { this.ptrs_to.add(b); };
75                 return ret;
76         }
77
78         @Override public boolean equals(Object o) {
79                 if (!(o instanceof OfferId)) return false;
80                 return this.eq((OfferId)o);
81         }
82         /**
83          * Serialize the OfferId object into a byte array which can be read by OfferId_read
84          */
85         public byte[] write() {
86                 byte[] ret = bindings.OfferId_write(this.ptr);
87                 Reference.reachabilityFence(this);
88                 return ret;
89         }
90
91         /**
92          * Read a OfferId from a byte array, created by OfferId_write
93          */
94         public static Result_OfferIdDecodeErrorZ read(byte[] ser) {
95                 long ret = bindings.OfferId_read(ser);
96                 Reference.reachabilityFence(ser);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 Result_OfferIdDecodeErrorZ ret_hu_conv = Result_OfferIdDecodeErrorZ.constr_from_ptr(ret);
99                 return ret_hu_conv;
100         }
101
102 }