[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / NodeAnnouncement.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 [`node_announcement`] message to be sent to or received from a peer.
13  * 
14  * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class NodeAnnouncement extends CommonBase {
18         NodeAnnouncement(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.NodeAnnouncement_free(ptr); }
23         }
24
25         /**
26          * The signature by the node key
27          */
28         public byte[] get_signature() {
29                 byte[] ret = bindings.NodeAnnouncement_get_signature(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The signature by the node key
36          */
37         public void set_signature(byte[] val) {
38                 bindings.NodeAnnouncement_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The actual content of the announcement
45          */
46         public UnsignedNodeAnnouncement get_contents() {
47                 long ret = bindings.NodeAnnouncement_get_contents(this.ptr);
48                 Reference.reachabilityFence(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * The actual content of the announcement
57          */
58         public void set_contents(org.ldk.structs.UnsignedNodeAnnouncement val) {
59                 bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr);
60                 Reference.reachabilityFence(this);
61                 Reference.reachabilityFence(val);
62                 if (this != null) { this.ptrs_to.add(val); };
63         }
64
65         /**
66          * Constructs a new NodeAnnouncement given each field
67          */
68         public static NodeAnnouncement of(byte[] signature_arg, org.ldk.structs.UnsignedNodeAnnouncement contents_arg) {
69                 long ret = bindings.NodeAnnouncement_new(InternalUtils.check_arr_len(signature_arg, 64), contents_arg == null ? 0 : contents_arg.ptr);
70                 Reference.reachabilityFence(signature_arg);
71                 Reference.reachabilityFence(contents_arg);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents_arg); };
76                 return ret_hu_conv;
77         }
78
79         long clone_ptr() {
80                 long ret = bindings.NodeAnnouncement_clone_ptr(this.ptr);
81                 Reference.reachabilityFence(this);
82                 return ret;
83         }
84
85         /**
86          * Creates a copy of the NodeAnnouncement
87          */
88         public NodeAnnouncement clone() {
89                 long ret = bindings.NodeAnnouncement_clone(this.ptr);
90                 Reference.reachabilityFence(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
99          */
100         public long hash() {
101                 long ret = bindings.NodeAnnouncement_hash(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         @Override public int hashCode() {
107                 return (int)this.hash();
108         }
109         /**
110          * Checks if two NodeAnnouncements contain equal inner contents.
111          * This ignores pointers and is_owned flags and looks at the values in fields.
112          * Two objects with NULL inner values will be considered "equal" here.
113          */
114         public boolean eq(org.ldk.structs.NodeAnnouncement b) {
115                 boolean ret = bindings.NodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
116                 Reference.reachabilityFence(this);
117                 Reference.reachabilityFence(b);
118                 if (this != null) { this.ptrs_to.add(b); };
119                 return ret;
120         }
121
122         @Override public boolean equals(Object o) {
123                 if (!(o instanceof NodeAnnouncement)) return false;
124                 return this.eq((NodeAnnouncement)o);
125         }
126         /**
127          * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
128          */
129         public byte[] write() {
130                 byte[] ret = bindings.NodeAnnouncement_write(this.ptr);
131                 Reference.reachabilityFence(this);
132                 return ret;
133         }
134
135         /**
136          * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
137          */
138         public static Result_NodeAnnouncementDecodeErrorZ read(byte[] ser) {
139                 long ret = bindings.NodeAnnouncement_read(ser);
140                 Reference.reachabilityFence(ser);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
143                 return ret_hu_conv;
144         }
145
146 }