[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / java / org / ldk / structs / Type.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  * Defines a type identifier for sending messages over the wire.
12  * 
13  * Messages implementing this trait specify a type and must be [`Writeable`].
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class Type extends CommonBase {
17         final bindings.LDKType bindings_instance;
18         Type(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
19         private Type(bindings.LDKType arg) {
20                 super(bindings.LDKType_new(arg));
21                 this.ptrs_to.add(arg);
22                 this.bindings_instance = arg;
23         }
24         @Override @SuppressWarnings("deprecation")
25         protected void finalize() throws Throwable {
26                 if (ptr != 0) { bindings.Type_free(ptr); } super.finalize();
27         }
28
29         public static interface TypeInterface {
30                 /**
31                  * Returns the type identifying the message payload.
32                  */
33                 short type_id();
34                 /**
35                  * Return a human-readable "debug" string describing this object
36                  */
37                 String debug_str();
38                 /**
39                  * Serialize the object into a byte array
40                  */
41                 byte[] write();
42         }
43         private static class LDKTypeHolder { Type held; }
44         public static Type new_impl(TypeInterface arg) {
45                 final LDKTypeHolder impl_holder = new LDKTypeHolder();
46                 impl_holder.held = new Type(new bindings.LDKType() {
47                         @Override public short type_id() {
48                                 short ret = arg.type_id();
49                                 Reference.reachabilityFence(arg);
50                                 return ret;
51                         }
52                         @Override public String debug_str() {
53                                 String ret = arg.debug_str();
54                                 Reference.reachabilityFence(arg);
55                                 return ret;
56                         }
57                         @Override public byte[] write() {
58                                 byte[] ret = arg.write();
59                                 Reference.reachabilityFence(arg);
60                                 return ret;
61                         }
62                 });
63                 return impl_holder.held;
64         }
65         /**
66          * Returns the type identifying the message payload.
67          */
68         public short type_id() {
69                 short ret = bindings.Type_type_id(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * Return a human-readable "debug" string describing this object
76          */
77         public String debug_str() {
78                 String ret = bindings.Type_debug_str(this.ptr);
79                 Reference.reachabilityFence(this);
80                 return ret;
81         }
82
83         /**
84          * Serialize the object into a byte array
85          */
86         public byte[] write() {
87                 byte[] ret = bindings.Type_write(this.ptr);
88                 Reference.reachabilityFence(this);
89                 return ret;
90         }
91
92         long clone_ptr() {
93                 long ret = bindings.Type_clone_ptr(this.ptr);
94                 Reference.reachabilityFence(this);
95                 return ret;
96         }
97
98         /**
99          * Creates a copy of a Type
100          */
101         public Type clone() {
102                 long ret = bindings.Type_clone(this.ptr);
103                 Reference.reachabilityFence(this);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 Type ret_hu_conv = new Type(null, ret);
106                 ret_hu_conv.ptrs_to.add(this);
107                 return ret_hu_conv;
108         }
109
110 }