79edade6192ab731a300f846322080ff691f2414
[ldk-java] / src / main / java / org / ldk / structs / CustomOnionMessageContents.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 a custom onion message.
12  */
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;
21         }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 if (ptr != 0) { bindings.CustomOnionMessageContents_free(ptr); } super.finalize();
25         }
26
27         public static interface CustomOnionMessageContentsInterface {
28                 /**
29                  * Returns the TLV type identifying the message contents. MUST be >= 64.
30                  */
31                 long tlv_type();
32                 /**
33                  * Serialize the object into a byte array
34                  */
35                 byte[] write();
36         }
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);
44                                 return ret;
45                         }
46                         @Override public byte[] write() {
47                                 byte[] ret = arg.write();
48                                 Reference.reachabilityFence(arg);
49                                 return ret;
50                         }
51                 });
52                 return impl_holder.held;
53         }
54         /**
55          * Returns the TLV type identifying the message contents. MUST be >= 64.
56          */
57         public long tlv_type() {
58                 long ret = bindings.CustomOnionMessageContents_tlv_type(this.ptr);
59                 Reference.reachabilityFence(this);
60                 return ret;
61         }
62
63         /**
64          * Serialize the object into a byte array
65          */
66         public byte[] write() {
67                 byte[] ret = bindings.CustomOnionMessageContents_write(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         long clone_ptr() {
73                 long ret = bindings.CustomOnionMessageContents_clone_ptr(this.ptr);
74                 Reference.reachabilityFence(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of a CustomOnionMessageContents
80          */
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); };
87                 return ret_hu_conv;
88         }
89
90 }