1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * An enum which can either contain a crate::lightning::ln::wire::Type or not
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class Option_TypeZ extends CommonBase {
15 private Option_TypeZ(Object _dummy, long ptr) { super(ptr); }
16 @Override @SuppressWarnings("deprecation")
17 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.COption_TypeZ_free(ptr); }
21 static Option_TypeZ constr_from_ptr(long ptr) {
22 bindings.LDKCOption_TypeZ raw_val = bindings.LDKCOption_TypeZ_ref_from_ptr(ptr);
23 if (raw_val.getClass() == bindings.LDKCOption_TypeZ.Some.class) {
24 return new Some(ptr, (bindings.LDKCOption_TypeZ.Some)raw_val);
26 if (raw_val.getClass() == bindings.LDKCOption_TypeZ.None.class) {
27 return new None(ptr, (bindings.LDKCOption_TypeZ.None)raw_val);
29 assert false; return null; // Unreachable without extending the (internal) bindings interface
32 public final static class Some extends Option_TypeZ {
33 public final Type some;
34 private Some(long ptr, bindings.LDKCOption_TypeZ.Some obj) {
37 Type ret_hu_conv = new Type(null, some);
38 ret_hu_conv.ptrs_to.add(this);
39 this.some = ret_hu_conv;
42 public final static class None extends Option_TypeZ {
43 private None(long ptr, bindings.LDKCOption_TypeZ.None obj) {
48 * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type
50 public static Option_TypeZ some(Type o) {
51 long ret = bindings.COption_TypeZ_some(o == null ? 0 : o.ptr);
52 if (ret < 1024) { return null; }
53 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
54 ret_hu_conv.ptrs_to.add(ret_hu_conv);
55 ret_hu_conv.ptrs_to.add(o);
60 * Constructs a new COption_TypeZ containing nothing
62 public static Option_TypeZ none() {
63 long ret = bindings.COption_TypeZ_none();
64 if (ret < 1024) { return null; }
65 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
66 ret_hu_conv.ptrs_to.add(ret_hu_conv);
71 * Creates a new COption_TypeZ which has the same data as `orig`
72 * but with all dynamically-allocated buffers duplicated in new buffers.
74 public Option_TypeZ clone() {
75 long ret = bindings.COption_TypeZ_clone(this.ptr);
76 if (ret < 1024) { return null; }
77 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
78 ret_hu_conv.ptrs_to.add(this);