[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / ErrorMessage.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  * An [`error`] message to be sent to or received from a peer.
13  * 
14  * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ErrorMessage extends CommonBase {
18         ErrorMessage(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ErrorMessage_free(ptr); }
23         }
24
25         /**
26          * The channel ID involved in the error.
27          * 
28          * All-0s indicates a general error unrelated to a specific channel, after which all channels
29          * with the sending peer should be closed.
30          */
31         public byte[] get_channel_id() {
32                 byte[] ret = bindings.ErrorMessage_get_channel_id(this.ptr);
33                 Reference.reachabilityFence(this);
34                 return ret;
35         }
36
37         /**
38          * The channel ID involved in the error.
39          * 
40          * All-0s indicates a general error unrelated to a specific channel, after which all channels
41          * with the sending peer should be closed.
42          */
43         public void set_channel_id(byte[] val) {
44                 bindings.ErrorMessage_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
45                 Reference.reachabilityFence(this);
46                 Reference.reachabilityFence(val);
47         }
48
49         /**
50          * A possibly human-readable error description.
51          * 
52          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
53          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
54          * the terminal emulator or the logging subsystem.
55          */
56         public String get_data() {
57                 String ret = bindings.ErrorMessage_get_data(this.ptr);
58                 Reference.reachabilityFence(this);
59                 return ret;
60         }
61
62         /**
63          * A possibly human-readable error description.
64          * 
65          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
66          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
67          * the terminal emulator or the logging subsystem.
68          */
69         public void set_data(java.lang.String val) {
70                 bindings.ErrorMessage_set_data(this.ptr, val);
71                 Reference.reachabilityFence(this);
72                 Reference.reachabilityFence(val);
73         }
74
75         /**
76          * Constructs a new ErrorMessage given each field
77          */
78         public static ErrorMessage of(byte[] channel_id_arg, java.lang.String data_arg) {
79                 long ret = bindings.ErrorMessage_new(InternalUtils.check_arr_len(channel_id_arg, 32), data_arg);
80                 Reference.reachabilityFence(channel_id_arg);
81                 Reference.reachabilityFence(data_arg);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
85                 return ret_hu_conv;
86         }
87
88         long clone_ptr() {
89                 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
90                 Reference.reachabilityFence(this);
91                 return ret;
92         }
93
94         /**
95          * Creates a copy of the ErrorMessage
96          */
97         public ErrorMessage clone() {
98                 long ret = bindings.ErrorMessage_clone(this.ptr);
99                 Reference.reachabilityFence(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
103                 return ret_hu_conv;
104         }
105
106         /**
107          * Generates a non-cryptographic 64-bit hash of the ErrorMessage.
108          */
109         public long hash() {
110                 long ret = bindings.ErrorMessage_hash(this.ptr);
111                 Reference.reachabilityFence(this);
112                 return ret;
113         }
114
115         @Override public int hashCode() {
116                 return (int)this.hash();
117         }
118         /**
119          * Checks if two ErrorMessages contain equal inner contents.
120          * This ignores pointers and is_owned flags and looks at the values in fields.
121          * Two objects with NULL inner values will be considered "equal" here.
122          */
123         public boolean eq(org.ldk.structs.ErrorMessage b) {
124                 boolean ret = bindings.ErrorMessage_eq(this.ptr, b == null ? 0 : b.ptr);
125                 Reference.reachabilityFence(this);
126                 Reference.reachabilityFence(b);
127                 if (this != null) { this.ptrs_to.add(b); };
128                 return ret;
129         }
130
131         @Override public boolean equals(Object o) {
132                 if (!(o instanceof ErrorMessage)) return false;
133                 return this.eq((ErrorMessage)o);
134         }
135         /**
136          * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
137          */
138         public byte[] write() {
139                 byte[] ret = bindings.ErrorMessage_write(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * Read a ErrorMessage from a byte array, created by ErrorMessage_write
146          */
147         public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
148                 long ret = bindings.ErrorMessage_read(ser);
149                 Reference.reachabilityFence(ser);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
152                 return ret_hu_conv;
153         }
154
155 }