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::lightning::ln::wire::Type or not
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Option_TypeZ extends CommonBase {
16 private Option_TypeZ(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.COption_TypeZ_free(ptr); }
22 static Option_TypeZ constr_from_ptr(long ptr) {
23 bindings.LDKCOption_TypeZ raw_val = bindings.LDKCOption_TypeZ_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKCOption_TypeZ.Some.class) {
25 return new Some(ptr, (bindings.LDKCOption_TypeZ.Some)raw_val);
27 if (raw_val.getClass() == bindings.LDKCOption_TypeZ.None.class) {
28 return new None(ptr, (bindings.LDKCOption_TypeZ.None)raw_val);
30 assert false; return null; // Unreachable without extending the (internal) bindings interface
34 * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type
36 public final static class Some extends Option_TypeZ {
37 public final Type some;
38 private Some(long ptr, bindings.LDKCOption_TypeZ.Some obj) {
41 Type ret_hu_conv = new Type(null, some);
42 ret_hu_conv.ptrs_to.add(this);
43 this.some = ret_hu_conv;
47 * When we're in this state, this COption_TypeZ contains nothing
49 public final static class None extends Option_TypeZ {
50 private None(long ptr, bindings.LDKCOption_TypeZ.None obj) {
55 * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type
57 public static Option_TypeZ some(Type o) {
58 long ret = bindings.COption_TypeZ_some(o == null ? 0 : o.ptr);
59 Reference.reachabilityFence(o);
60 if (ret >= 0 && ret <= 4096) { return null; }
61 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
62 ret_hu_conv.ptrs_to.add(ret_hu_conv);
63 ret_hu_conv.ptrs_to.add(o);
68 * Constructs a new COption_TypeZ containing nothing
70 public static Option_TypeZ none() {
71 long ret = bindings.COption_TypeZ_none();
72 if (ret >= 0 && ret <= 4096) { return null; }
73 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
74 ret_hu_conv.ptrs_to.add(ret_hu_conv);
79 long ret = bindings.COption_TypeZ_clone_ptr(this.ptr);
80 Reference.reachabilityFence(this);
85 * Creates a new COption_TypeZ which has the same data as `orig`
86 * but with all dynamically-allocated buffers duplicated in new buffers.
88 public Option_TypeZ clone() {
89 long ret = bindings.COption_TypeZ_clone(this.ptr);
90 Reference.reachabilityFence(this);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
93 ret_hu_conv.ptrs_to.add(this);