10ca05825ebbe7b41be88f2d13e1715e038cdcea
[ldk-java] / c_sharp / src / org / ldk / structs / Option_MonitorEventZ.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not
10  */
11 public class Option_MonitorEventZ : CommonBase {
12         protected Option_MonitorEventZ(object _dummy, long ptr) : base(ptr) { }
13         ~Option_MonitorEventZ() {
14                 if (ptr != 0) { bindings.COption_MonitorEventZ_free(ptr); }
15         }
16
17         internal static Option_MonitorEventZ constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKCOption_MonitorEventZ_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new Option_MonitorEventZ_Some(ptr);
21                         case 1: return new Option_MonitorEventZ_None(ptr);
22                         default:
23                                 throw new ArgumentException("Impossible enum variant");
24                 }
25         }
26
27         /** A Option_MonitorEventZ of type Some */
28         public class Option_MonitorEventZ_Some : Option_MonitorEventZ {
29                 public MonitorEvent some;
30                 internal Option_MonitorEventZ_Some(long ptr) : base(null, ptr) {
31                         long some = bindings.LDKCOption_MonitorEventZ_Some_get_some(ptr);
32                         org.ldk.structs.MonitorEvent some_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(some);
33                         if (some_hu_conv != null) { some_hu_conv.ptrs_to.AddLast(this); };
34                         this.some = some_hu_conv;
35                 }
36         }
37         /** A Option_MonitorEventZ of type None */
38         public class Option_MonitorEventZ_None : Option_MonitorEventZ {
39                 internal Option_MonitorEventZ_None(long ptr) : base(null, ptr) {
40                 }
41         }
42         /**
43          * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent
44          */
45         public static Option_MonitorEventZ some(org.ldk.structs.MonitorEvent o) {
46                 long ret = bindings.COption_MonitorEventZ_some(o.ptr);
47                 GC.KeepAlive(o);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 org.ldk.structs.Option_MonitorEventZ ret_hu_conv = org.ldk.structs.Option_MonitorEventZ.constr_from_ptr(ret);
50                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
51                 return ret_hu_conv;
52         }
53
54         /**
55          * Constructs a new COption_MonitorEventZ containing nothing
56          */
57         public static Option_MonitorEventZ none() {
58                 long ret = bindings.COption_MonitorEventZ_none();
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 org.ldk.structs.Option_MonitorEventZ ret_hu_conv = org.ldk.structs.Option_MonitorEventZ.constr_from_ptr(ret);
61                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
62                 return ret_hu_conv;
63         }
64
65         internal long clone_ptr() {
66                 long ret = bindings.COption_MonitorEventZ_clone_ptr(this.ptr);
67                 GC.KeepAlive(this);
68                 return ret;
69         }
70
71         /**
72          * Creates a new COption_MonitorEventZ which has the same data as `orig`
73          * but with all dynamically-allocated buffers duplicated in new buffers.
74          */
75         public Option_MonitorEventZ clone() {
76                 long ret = bindings.COption_MonitorEventZ_clone(this.ptr);
77                 GC.KeepAlive(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.Option_MonitorEventZ ret_hu_conv = org.ldk.structs.Option_MonitorEventZ.constr_from_ptr(ret);
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
81                 return ret_hu_conv;
82         }
83
84 }
85 } } }