[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / OnionMessageContents.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * The contents of an onion message.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class OnionMessageContents extends CommonBase {
15         final bindings.LDKOnionMessageContents bindings_instance;
16         OnionMessageContents(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
17         private OnionMessageContents(bindings.LDKOnionMessageContents arg) {
18                 super(bindings.LDKOnionMessageContents_new(arg));
19                 this.ptrs_to.add(arg);
20                 this.bindings_instance = arg;
21         }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 if (ptr != 0) { bindings.OnionMessageContents_free(ptr); } super.finalize();
25         }
26         /**
27          * Destroys the object, freeing associated resources. After this call, any access
28          * to this object may result in a SEGFAULT or worse.
29          *
30          * You should generally NEVER call this method. You should let the garbage collector
31          * do this for you when it finalizes objects. However, it may be useful for types
32          * which represent locks and should be closed immediately to avoid holding locks
33          * until the GC runs.
34          */
35         public void destroy() {
36                 if (ptr != 0) { bindings.OnionMessageContents_free(ptr); }
37                 ptr = 0;
38         }
39         public static interface OnionMessageContentsInterface {
40                 /**
41                  * Returns the TLV type identifying the message contents. MUST be >= 64.
42                  */
43                 long tlv_type();
44                 /**
45                  * Serialize the object into a byte array
46                  */
47                 byte[] write();
48                 /**
49                  * Return a human-readable "debug" string describing this object
50                  */
51                 String debug_str();
52         }
53         private static class LDKOnionMessageContentsHolder { OnionMessageContents held; }
54         public static OnionMessageContents new_impl(OnionMessageContentsInterface arg) {
55                 final LDKOnionMessageContentsHolder impl_holder = new LDKOnionMessageContentsHolder();
56                 impl_holder.held = new OnionMessageContents(new bindings.LDKOnionMessageContents() {
57                         @Override public long tlv_type() {
58                                 long ret = arg.tlv_type();
59                                 Reference.reachabilityFence(arg);
60                                 return ret;
61                         }
62                         @Override public byte[] write() {
63                                 byte[] ret = arg.write();
64                                 Reference.reachabilityFence(arg);
65                                 return ret;
66                         }
67                         @Override public String debug_str() {
68                                 String ret = arg.debug_str();
69                                 Reference.reachabilityFence(arg);
70                                 return ret;
71                         }
72                 });
73                 return impl_holder.held;
74         }
75         /**
76          * Returns the TLV type identifying the message contents. MUST be >= 64.
77          */
78         public long tlv_type() {
79                 long ret = bindings.OnionMessageContents_tlv_type(this.ptr);
80                 Reference.reachabilityFence(this);
81                 return ret;
82         }
83
84         /**
85          * Serialize the object into a byte array
86          */
87         public byte[] write() {
88                 byte[] ret = bindings.OnionMessageContents_write(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * Return a human-readable "debug" string describing this object
95          */
96         public String debug_str() {
97                 String ret = bindings.OnionMessageContents_debug_str(this.ptr);
98                 Reference.reachabilityFence(this);
99                 return ret;
100         }
101
102         long clone_ptr() {
103                 long ret = bindings.OnionMessageContents_clone_ptr(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         /**
109          * Creates a copy of a OnionMessageContents
110          */
111         public OnionMessageContents clone() {
112                 long ret = bindings.OnionMessageContents_clone(this.ptr);
113                 Reference.reachabilityFence(this);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 OnionMessageContents ret_hu_conv = new OnionMessageContents(null, ret);
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
117                 return ret_hu_conv;
118         }
119
120 }