[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / NodeAlias.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 /**
12  * A user-defined name for a node, which may be used when displaying the node in a graph.
13  * 
14  * Since node aliases are provided by third parties, they are a potential avenue for injection
15  * attacks. Care must be taken when processing.
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class NodeAlias extends CommonBase {
19         NodeAlias(Object _dummy, long ptr) { super(ptr); }
20         @Override @SuppressWarnings("deprecation")
21         protected void finalize() throws Throwable {
22                 super.finalize();
23                 if (ptr != 0) { bindings.NodeAlias_free(ptr); }
24         }
25
26         public byte[] get_a() {
27                 byte[] ret = bindings.NodeAlias_get_a(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         public void set_a(byte[] val) {
33                 bindings.NodeAlias_set_a(this.ptr, InternalUtils.check_arr_len(val, 32));
34                 Reference.reachabilityFence(this);
35                 Reference.reachabilityFence(val);
36         }
37
38         /**
39          * Constructs a new NodeAlias given each field
40          */
41         public static NodeAlias of(byte[] a_arg) {
42                 long ret = bindings.NodeAlias_new(InternalUtils.check_arr_len(a_arg, 32));
43                 Reference.reachabilityFence(a_arg);
44                 if (ret >= 0 && ret <= 4096) { return null; }
45                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
46                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
47                 return ret_hu_conv;
48         }
49
50         long clone_ptr() {
51                 long ret = bindings.NodeAlias_clone_ptr(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * Creates a copy of the NodeAlias
58          */
59         public NodeAlias clone() {
60                 long ret = bindings.NodeAlias_clone(this.ptr);
61                 Reference.reachabilityFence(this);
62                 if (ret >= 0 && ret <= 4096) { return null; }
63                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
64                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
65                 return ret_hu_conv;
66         }
67
68         /**
69          * Generates a non-cryptographic 64-bit hash of the NodeAlias.
70          */
71         public long hash() {
72                 long ret = bindings.NodeAlias_hash(this.ptr);
73                 Reference.reachabilityFence(this);
74                 return ret;
75         }
76
77         @Override public int hashCode() {
78                 return (int)this.hash();
79         }
80         /**
81          * Checks if two NodeAliass contain equal inner contents.
82          * This ignores pointers and is_owned flags and looks at the values in fields.
83          * Two objects with NULL inner values will be considered "equal" here.
84          */
85         public boolean eq(org.ldk.structs.NodeAlias b) {
86                 boolean ret = bindings.NodeAlias_eq(this.ptr, b == null ? 0 : b.ptr);
87                 Reference.reachabilityFence(this);
88                 Reference.reachabilityFence(b);
89                 if (this != null) { this.ptrs_to.add(b); };
90                 return ret;
91         }
92
93         @Override public boolean equals(Object o) {
94                 if (!(o instanceof NodeAlias)) return false;
95                 return this.eq((NodeAlias)o);
96         }
97         /**
98          * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read
99          */
100         public byte[] write() {
101                 byte[] ret = bindings.NodeAlias_write(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * Read a NodeAlias from a byte array, created by NodeAlias_write
108          */
109         public static Result_NodeAliasDecodeErrorZ read(byte[] ser) {
110                 long ret = bindings.NodeAlias_read(ser);
111                 Reference.reachabilityFence(ser);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 Result_NodeAliasDecodeErrorZ ret_hu_conv = Result_NodeAliasDecodeErrorZ.constr_from_ptr(ret);
114                 return ret_hu_conv;
115         }
116
117 }