[TS] Slightly improve logging in TS trait calls that fail
[ldk-java] / src / main / java / org / ldk / structs / Ping.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 ping message to be sent or received from a peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Ping extends CommonBase {
16         Ping(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Ping_free(ptr); }
21         }
22
23         /**
24          * The desired response length
25          */
26         public short get_ponglen() {
27                 short ret = bindings.Ping_get_ponglen(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The desired response length
34          */
35         public void set_ponglen(short val) {
36                 bindings.Ping_set_ponglen(this.ptr, val);
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The ping packet size.
43          * This field is not sent on the wire. byteslen zeros are sent.
44          */
45         public short get_byteslen() {
46                 short ret = bindings.Ping_get_byteslen(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         /**
52          * The ping packet size.
53          * This field is not sent on the wire. byteslen zeros are sent.
54          */
55         public void set_byteslen(short val) {
56                 bindings.Ping_set_byteslen(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * Constructs a new Ping given each field
63          */
64         public static Ping of(short ponglen_arg, short byteslen_arg) {
65                 long ret = bindings.Ping_new(ponglen_arg, byteslen_arg);
66                 Reference.reachabilityFence(ponglen_arg);
67                 Reference.reachabilityFence(byteslen_arg);
68                 if (ret >= 0 && ret <= 4096) { return null; }
69                 org.ldk.structs.Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Ping(null, ret); }
70                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
71                 return ret_hu_conv;
72         }
73
74         long clone_ptr() {
75                 long ret = bindings.Ping_clone_ptr(this.ptr);
76                 Reference.reachabilityFence(this);
77                 return ret;
78         }
79
80         /**
81          * Creates a copy of the Ping
82          */
83         public Ping clone() {
84                 long ret = bindings.Ping_clone(this.ptr);
85                 Reference.reachabilityFence(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Ping(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Checks if two Pings contain equal inner contents.
94          * This ignores pointers and is_owned flags and looks at the values in fields.
95          * Two objects with NULL inner values will be considered "equal" here.
96          */
97         public boolean eq(org.ldk.structs.Ping b) {
98                 boolean ret = bindings.Ping_eq(this.ptr, b == null ? 0 : b.ptr);
99                 Reference.reachabilityFence(this);
100                 Reference.reachabilityFence(b);
101                 if (this != null) { this.ptrs_to.add(b); };
102                 return ret;
103         }
104
105         @Override public boolean equals(Object o) {
106                 if (!(o instanceof Ping)) return false;
107                 return this.eq((Ping)o);
108         }
109         /**
110          * Serialize the Ping object into a byte array which can be read by Ping_read
111          */
112         public byte[] write() {
113                 byte[] ret = bindings.Ping_write(this.ptr);
114                 Reference.reachabilityFence(this);
115                 return ret;
116         }
117
118         /**
119          * Read a Ping from a byte array, created by Ping_write
120          */
121         public static Result_PingDecodeErrorZ read(byte[] ser) {
122                 long ret = bindings.Ping_read(ser);
123                 Reference.reachabilityFence(ser);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);
126                 return ret_hu_conv;
127         }
128
129 }