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 public static interface CustomOnionMessageContentsInterface {
29 * Returns the TLV type identifying the message contents. MUST be >= 64.
33 * Serialize the object into a byte array
37 private static class LDKCustomOnionMessageContentsHolder { CustomOnionMessageContents held; }
38 public static CustomOnionMessageContents new_impl(CustomOnionMessageContentsInterface arg) {
39 final LDKCustomOnionMessageContentsHolder impl_holder = new LDKCustomOnionMessageContentsHolder();
40 impl_holder.held = new CustomOnionMessageContents(new bindings.LDKCustomOnionMessageContents() {
41 @Override public long tlv_type() {
42 long ret = arg.tlv_type();
43 Reference.reachabilityFence(arg);
46 @Override public byte[] write() {
47 byte[] ret = arg.write();
48 Reference.reachabilityFence(arg);
52 return impl_holder.held;
55 * Returns the TLV type identifying the message contents. MUST be >= 64.
57 public long tlv_type() {
58 long ret = bindings.CustomOnionMessageContents_tlv_type(this.ptr);
59 Reference.reachabilityFence(this);
64 * Serialize the object into a byte array
66 public byte[] write() {
67 byte[] ret = bindings.CustomOnionMessageContents_write(this.ptr);
68 Reference.reachabilityFence(this);
73 long ret = bindings.CustomOnionMessageContents_clone_ptr(this.ptr);
74 Reference.reachabilityFence(this);
79 * Creates a copy of a CustomOnionMessageContents
81 public CustomOnionMessageContents clone() {
82 long ret = bindings.CustomOnionMessageContents_clone(this.ptr);
83 Reference.reachabilityFence(this);
84 if (ret >= 0 && ret <= 4096) { return null; }
85 CustomOnionMessageContents ret_hu_conv = new CustomOnionMessageContents(null, ret);
86 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };