[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / Pong.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 [`pong`] message to be sent to or received from a peer.
13  * 
14  * [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Pong extends CommonBase {
18         Pong(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.Pong_free(ptr); }
23         }
24
25         /**
26          * The pong packet size.
27          * 
28          * This field is not sent on the wire. byteslen zeros are sent.
29          */
30         public short get_byteslen() {
31                 short ret = bindings.Pong_get_byteslen(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * The pong packet size.
38          * 
39          * This field is not sent on the wire. byteslen zeros are sent.
40          */
41         public void set_byteslen(short val) {
42                 bindings.Pong_set_byteslen(this.ptr, val);
43                 Reference.reachabilityFence(this);
44                 Reference.reachabilityFence(val);
45         }
46
47         /**
48          * Constructs a new Pong given each field
49          */
50         public static Pong of(short byteslen_arg) {
51                 long ret = bindings.Pong_new(byteslen_arg);
52                 Reference.reachabilityFence(byteslen_arg);
53                 if (ret >= 0 && ret <= 4096) { return null; }
54                 org.ldk.structs.Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Pong(null, ret); }
55                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
56                 return ret_hu_conv;
57         }
58
59         long clone_ptr() {
60                 long ret = bindings.Pong_clone_ptr(this.ptr);
61                 Reference.reachabilityFence(this);
62                 return ret;
63         }
64
65         /**
66          * Creates a copy of the Pong
67          */
68         public Pong clone() {
69                 long ret = bindings.Pong_clone(this.ptr);
70                 Reference.reachabilityFence(this);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Pong(null, ret); }
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Generates a non-cryptographic 64-bit hash of the Pong.
79          */
80         public long hash() {
81                 long ret = bindings.Pong_hash(this.ptr);
82                 Reference.reachabilityFence(this);
83                 return ret;
84         }
85
86         @Override public int hashCode() {
87                 return (int)this.hash();
88         }
89         /**
90          * Checks if two Pongs contain equal inner contents.
91          * This ignores pointers and is_owned flags and looks at the values in fields.
92          * Two objects with NULL inner values will be considered "equal" here.
93          */
94         public boolean eq(org.ldk.structs.Pong b) {
95                 boolean ret = bindings.Pong_eq(this.ptr, b == null ? 0 : b.ptr);
96                 Reference.reachabilityFence(this);
97                 Reference.reachabilityFence(b);
98                 if (this != null) { this.ptrs_to.add(b); };
99                 return ret;
100         }
101
102         @Override public boolean equals(Object o) {
103                 if (!(o instanceof Pong)) return false;
104                 return this.eq((Pong)o);
105         }
106         /**
107          * Serialize the Pong object into a byte array which can be read by Pong_read
108          */
109         public byte[] write() {
110                 byte[] ret = bindings.Pong_write(this.ptr);
111                 Reference.reachabilityFence(this);
112                 return ret;
113         }
114
115         /**
116          * Read a Pong from a byte array, created by Pong_write
117          */
118         public static Result_PongDecodeErrorZ read(byte[] ser) {
119                 long ret = bindings.Pong_read(ser);
120                 Reference.reachabilityFence(ser);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);
123                 return ret_hu_conv;
124         }
125
126 }