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 * The context of a payment made for an invoice sent for a BOLT 12 [`Refund`].
14 * [`Refund`]: crate::offers::refund::Refund
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Bolt12RefundContext extends CommonBase {
18 Bolt12RefundContext(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.Bolt12RefundContext_free(ptr); }
26 * Constructs a new Bolt12RefundContext given each field
28 public static Bolt12RefundContext of() {
29 long ret = bindings.Bolt12RefundContext_new();
30 if (ret >= 0 && ret <= 4096) { return null; }
31 org.ldk.structs.Bolt12RefundContext ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12RefundContext(null, ret); }
32 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
37 long ret = bindings.Bolt12RefundContext_clone_ptr(this.ptr);
38 Reference.reachabilityFence(this);
43 * Creates a copy of the Bolt12RefundContext
45 public Bolt12RefundContext clone() {
46 long ret = bindings.Bolt12RefundContext_clone(this.ptr);
47 Reference.reachabilityFence(this);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 org.ldk.structs.Bolt12RefundContext ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12RefundContext(null, ret); }
50 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
55 * Checks if two Bolt12RefundContexts contain equal inner contents.
56 * This ignores pointers and is_owned flags and looks at the values in fields.
57 * Two objects with NULL inner values will be considered "equal" here.
59 public boolean eq(org.ldk.structs.Bolt12RefundContext b) {
60 boolean ret = bindings.Bolt12RefundContext_eq(this.ptr, b.ptr);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(b);
63 if (this != null) { this.ptrs_to.add(b); };
67 @Override public boolean equals(Object o) {
68 if (!(o instanceof Bolt12RefundContext)) return false;
69 return this.eq((Bolt12RefundContext)o);
72 * Serialize the Bolt12RefundContext object into a byte array which can be read by Bolt12RefundContext_read
74 public byte[] write() {
75 byte[] ret = bindings.Bolt12RefundContext_write(this.ptr);
76 Reference.reachabilityFence(this);
81 * Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write
83 public static Result_Bolt12RefundContextDecodeErrorZ read(byte[] ser) {
84 long ret = bindings.Bolt12RefundContext_read(ser);
85 Reference.reachabilityFence(ser);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 Result_Bolt12RefundContextDecodeErrorZ ret_hu_conv = Result_Bolt12RefundContextDecodeErrorZ.constr_from_ptr(ret);