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 enum which can either contain a crate::c_types::TxOut or not
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Option_TxOutZ extends CommonBase {
16 private Option_TxOutZ(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.COption_TxOutZ_free(ptr); }
22 static Option_TxOutZ constr_from_ptr(long ptr) {
23 bindings.LDKCOption_TxOutZ raw_val = bindings.LDKCOption_TxOutZ_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKCOption_TxOutZ.Some.class) {
25 return new Some(ptr, (bindings.LDKCOption_TxOutZ.Some)raw_val);
27 if (raw_val.getClass() == bindings.LDKCOption_TxOutZ.None.class) {
28 return new None(ptr, (bindings.LDKCOption_TxOutZ.None)raw_val);
30 assert false; return null; // Unreachable without extending the (internal) bindings interface
34 * When we're in this state, this COption_TxOutZ contains a crate::c_types::TxOut
36 public final static class Some extends Option_TxOutZ {
37 public final org.ldk.structs.TxOut some;
38 private Some(long ptr, bindings.LDKCOption_TxOutZ.Some obj) {
41 TxOut some_conv = new TxOut(null, some);
42 this.some = some_conv;
46 * When we're in this state, this COption_TxOutZ contains nothing
48 public final static class None extends Option_TxOutZ {
49 private None(long ptr, bindings.LDKCOption_TxOutZ.None obj) {
54 * Constructs a new COption_TxOutZ containing a crate::c_types::TxOut
56 public static Option_TxOutZ some(org.ldk.structs.TxOut o) {
57 long ret = bindings.COption_TxOutZ_some(o.ptr);
58 Reference.reachabilityFence(o);
59 if (ret >= 0 && ret <= 4096) { return null; }
60 org.ldk.structs.Option_TxOutZ ret_hu_conv = org.ldk.structs.Option_TxOutZ.constr_from_ptr(ret);
61 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
66 * Constructs a new COption_TxOutZ containing nothing
68 public static Option_TxOutZ none() {
69 long ret = bindings.COption_TxOutZ_none();
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.Option_TxOutZ ret_hu_conv = org.ldk.structs.Option_TxOutZ.constr_from_ptr(ret);
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
77 long ret = bindings.COption_TxOutZ_clone_ptr(this.ptr);
78 Reference.reachabilityFence(this);
83 * Creates a new COption_TxOutZ which has the same data as `orig`
84 * but with all dynamically-allocated buffers duplicated in new buffers.
86 public Option_TxOutZ clone() {
87 long ret = bindings.COption_TxOutZ_clone(this.ptr);
88 Reference.reachabilityFence(this);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.Option_TxOutZ ret_hu_conv = org.ldk.structs.Option_TxOutZ.constr_from_ptr(ret);
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };