1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * An identifier for an [`Offer`] built using [`DerivedMetadata`].
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 {
20 if (ptr != 0) { bindings.OfferId_free(ptr); }
23 public byte[] get_a() {
24 byte[] ret = bindings.OfferId_get_a(this.ptr);
25 Reference.reachabilityFence(this);
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);
36 * Constructs a new OfferId given each field
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); };
48 long ret = bindings.OfferId_clone_ptr(this.ptr);
49 Reference.reachabilityFence(this);
54 * Creates a copy of the OfferId
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); };
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.
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); };
78 @Override public boolean equals(Object o) {
79 if (!(o instanceof OfferId)) return false;
80 return this.eq((OfferId)o);
83 * Serialize the OfferId object into a byte array which can be read by OfferId_read
85 public byte[] write() {
86 byte[] ret = bindings.OfferId_write(this.ptr);
87 Reference.reachabilityFence(this);
92 * Read a OfferId from a byte array, created by OfferId_write
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);