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