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;
11 * The contents of a custom onion message.
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class CustomOnionMessageContents extends CommonBase {
15 final bindings.LDKCustomOnionMessageContents bindings_instance;
16 CustomOnionMessageContents(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
17 private CustomOnionMessageContents(bindings.LDKCustomOnionMessageContents arg) {
18 super(bindings.LDKCustomOnionMessageContents_new(arg));
19 this.ptrs_to.add(arg);
20 this.bindings_instance = arg;
22 @Override @SuppressWarnings("deprecation")
23 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.CustomOnionMessageContents_free(ptr); } super.finalize();
27 * Destroys the object, freeing associated resources. After this call, any access
28 * to this object may result in a SEGFAULT or worse.
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
35 public void destroy() {
36 if (ptr != 0) { bindings.CustomOnionMessageContents_free(ptr); }
39 public static interface CustomOnionMessageContentsInterface {
41 * Returns the TLV type identifying the message contents. MUST be >= 64.
45 * Serialize the object into a byte array
49 private static class LDKCustomOnionMessageContentsHolder { CustomOnionMessageContents held; }
50 public static CustomOnionMessageContents new_impl(CustomOnionMessageContentsInterface arg) {
51 final LDKCustomOnionMessageContentsHolder impl_holder = new LDKCustomOnionMessageContentsHolder();
52 impl_holder.held = new CustomOnionMessageContents(new bindings.LDKCustomOnionMessageContents() {
53 @Override public long tlv_type() {
54 long ret = arg.tlv_type();
55 Reference.reachabilityFence(arg);
58 @Override public byte[] write() {
59 byte[] ret = arg.write();
60 Reference.reachabilityFence(arg);
64 return impl_holder.held;
67 * Returns the TLV type identifying the message contents. MUST be >= 64.
69 public long tlv_type() {
70 long ret = bindings.CustomOnionMessageContents_tlv_type(this.ptr);
71 Reference.reachabilityFence(this);
76 * Serialize the object into a byte array
78 public byte[] write() {
79 byte[] ret = bindings.CustomOnionMessageContents_write(this.ptr);
80 Reference.reachabilityFence(this);
85 long ret = bindings.CustomOnionMessageContents_clone_ptr(this.ptr);
86 Reference.reachabilityFence(this);
91 * Creates a copy of a CustomOnionMessageContents
93 public CustomOnionMessageContents clone() {
94 long ret = bindings.CustomOnionMessageContents_clone(this.ptr);
95 Reference.reachabilityFence(this);
96 if (ret >= 0 && ret <= 4096) { return null; }
97 CustomOnionMessageContents ret_hu_conv = new CustomOnionMessageContents(null, ret);
98 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };