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::chain::channelmonitor::MonitorEvent or not
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Option_MonitorEventZ extends CommonBase {
16 private Option_MonitorEventZ(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.COption_MonitorEventZ_free(ptr); }
22 static Option_MonitorEventZ constr_from_ptr(long ptr) {
23 bindings.LDKCOption_MonitorEventZ raw_val = bindings.LDKCOption_MonitorEventZ_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKCOption_MonitorEventZ.Some.class) {
25 return new Some(ptr, (bindings.LDKCOption_MonitorEventZ.Some)raw_val);
27 if (raw_val.getClass() == bindings.LDKCOption_MonitorEventZ.None.class) {
28 return new None(ptr, (bindings.LDKCOption_MonitorEventZ.None)raw_val);
30 assert false; return null; // Unreachable without extending the (internal) bindings interface
34 * When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent
36 public final static class Some extends Option_MonitorEventZ {
37 public final org.ldk.structs.MonitorEvent some;
38 private Some(long ptr, bindings.LDKCOption_MonitorEventZ.Some obj) {
41 org.ldk.structs.MonitorEvent some_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(some);
42 some_hu_conv.ptrs_to.add(this);
43 this.some = some_hu_conv;
47 * When we're in this state, this COption_MonitorEventZ contains nothing
49 public final static class None extends Option_MonitorEventZ {
50 private None(long ptr, bindings.LDKCOption_MonitorEventZ.None obj) {
55 * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent
57 public static Option_MonitorEventZ some(MonitorEvent o) {
58 long ret = bindings.COption_MonitorEventZ_some(o.ptr);
59 Reference.reachabilityFence(o);
60 if (ret >= 0 && ret <= 4096) { return null; }
61 org.ldk.structs.Option_MonitorEventZ ret_hu_conv = org.ldk.structs.Option_MonitorEventZ.constr_from_ptr(ret);
62 ret_hu_conv.ptrs_to.add(ret_hu_conv);
67 * Constructs a new COption_MonitorEventZ containing nothing
69 public static Option_MonitorEventZ none() {
70 long ret = bindings.COption_MonitorEventZ_none();
71 if (ret >= 0 && ret <= 4096) { return null; }
72 org.ldk.structs.Option_MonitorEventZ ret_hu_conv = org.ldk.structs.Option_MonitorEventZ.constr_from_ptr(ret);
73 ret_hu_conv.ptrs_to.add(ret_hu_conv);
78 long ret = bindings.COption_MonitorEventZ_clone_ptr(this.ptr);
79 Reference.reachabilityFence(this);
84 * Creates a new COption_MonitorEventZ which has the same data as `orig`
85 * but with all dynamically-allocated buffers duplicated in new buffers.
87 public Option_MonitorEventZ clone() {
88 long ret = bindings.COption_MonitorEventZ_clone(this.ptr);
89 Reference.reachabilityFence(this);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.Option_MonitorEventZ ret_hu_conv = org.ldk.structs.Option_MonitorEventZ.constr_from_ptr(ret);
92 ret_hu_conv.ptrs_to.add(this);