[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / ErrorAction.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  * Used to put an error message in a LightningError
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ErrorAction extends CommonBase {
16         private ErrorAction(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ErrorAction_free(ptr); }
21         }
22         static ErrorAction constr_from_ptr(long ptr) {
23                 bindings.LDKErrorAction raw_val = bindings.LDKErrorAction_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKErrorAction.DisconnectPeer.class) {
25                         return new DisconnectPeer(ptr, (bindings.LDKErrorAction.DisconnectPeer)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreError.class) {
28                         return new IgnoreError(ptr, (bindings.LDKErrorAction.IgnoreError)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreAndLog.class) {
31                         return new IgnoreAndLog(ptr, (bindings.LDKErrorAction.IgnoreAndLog)raw_val);
32                 }
33                 if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreDuplicateGossip.class) {
34                         return new IgnoreDuplicateGossip(ptr, (bindings.LDKErrorAction.IgnoreDuplicateGossip)raw_val);
35                 }
36                 if (raw_val.getClass() == bindings.LDKErrorAction.SendErrorMessage.class) {
37                         return new SendErrorMessage(ptr, (bindings.LDKErrorAction.SendErrorMessage)raw_val);
38                 }
39                 if (raw_val.getClass() == bindings.LDKErrorAction.SendWarningMessage.class) {
40                         return new SendWarningMessage(ptr, (bindings.LDKErrorAction.SendWarningMessage)raw_val);
41                 }
42                 assert false; return null; // Unreachable without extending the (internal) bindings interface
43         }
44
45         /**
46          * The peer took some action which made us think they were useless. Disconnect them.
47          */
48         public final static class DisconnectPeer extends ErrorAction {
49                 /**
50                  * An error message which we should make an effort to send before we disconnect.
51                  * 
52                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
53                 */
54                 @Nullable public final org.ldk.structs.ErrorMessage msg;
55                 private DisconnectPeer(long ptr, bindings.LDKErrorAction.DisconnectPeer obj) {
56                         super(null, ptr);
57                         long msg = obj.msg;
58                         ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); }
59                         msg_hu_conv.ptrs_to.add(this);
60                         this.msg = msg_hu_conv;
61                 }
62         }
63         /**
64          * The peer did something harmless that we weren't able to process, just log and ignore
65          */
66         public final static class IgnoreError extends ErrorAction {
67                 private IgnoreError(long ptr, bindings.LDKErrorAction.IgnoreError obj) {
68                         super(null, ptr);
69                 }
70         }
71         /**
72          * The peer did something harmless that we weren't able to meaningfully process.
73          * If the error is logged, log it at the given level.
74          */
75         public final static class IgnoreAndLog extends ErrorAction {
76                 public final org.ldk.enums.Level ignore_and_log;
77                 private IgnoreAndLog(long ptr, bindings.LDKErrorAction.IgnoreAndLog obj) {
78                         super(null, ptr);
79                         this.ignore_and_log = obj.ignore_and_log;
80                 }
81         }
82         /**
83          * The peer provided us with a gossip message which we'd already seen. In most cases this
84          * should be ignored, but it may result in the message being forwarded if it is a duplicate of
85          * our own channel announcements.
86          */
87         public final static class IgnoreDuplicateGossip extends ErrorAction {
88                 private IgnoreDuplicateGossip(long ptr, bindings.LDKErrorAction.IgnoreDuplicateGossip obj) {
89                         super(null, ptr);
90                 }
91         }
92         /**
93          * The peer did something incorrect. Tell them.
94          */
95         public final static class SendErrorMessage extends ErrorAction {
96                 /**
97                  * The message to send.
98                 */
99                 public final org.ldk.structs.ErrorMessage msg;
100                 private SendErrorMessage(long ptr, bindings.LDKErrorAction.SendErrorMessage obj) {
101                         super(null, ptr);
102                         long msg = obj.msg;
103                         ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); }
104                         msg_hu_conv.ptrs_to.add(this);
105                         this.msg = msg_hu_conv;
106                 }
107         }
108         /**
109          * The peer did something incorrect. Tell them without closing any channels.
110          */
111         public final static class SendWarningMessage extends ErrorAction {
112                 /**
113                  * The message to send.
114                 */
115                 public final org.ldk.structs.WarningMessage msg;
116                 /**
117                  * The peer may have done something harmless that we weren't able to meaningfully process,
118                  * though we should still tell them about it.
119                  * If this event is logged, log it at the given level.
120                 */
121                 public final org.ldk.enums.Level log_level;
122                 private SendWarningMessage(long ptr, bindings.LDKErrorAction.SendWarningMessage obj) {
123                         super(null, ptr);
124                         long msg = obj.msg;
125                         WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new WarningMessage(null, msg); }
126                         msg_hu_conv.ptrs_to.add(this);
127                         this.msg = msg_hu_conv;
128                         this.log_level = obj.log_level;
129                 }
130         }
131         long clone_ptr() {
132                 long ret = bindings.ErrorAction_clone_ptr(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * Creates a copy of the ErrorAction
139          */
140         public ErrorAction clone() {
141                 long ret = bindings.ErrorAction_clone(this.ptr);
142                 Reference.reachabilityFence(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
145                 ret_hu_conv.ptrs_to.add(this);
146                 return ret_hu_conv;
147         }
148
149         /**
150          * Utility method to constructs a new DisconnectPeer-variant ErrorAction
151          */
152         public static ErrorAction disconnect_peer(ErrorMessage msg) {
153                 long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr & ~1);
154                 Reference.reachabilityFence(msg);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
157                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
158                 return ret_hu_conv;
159         }
160
161         /**
162          * Utility method to constructs a new IgnoreError-variant ErrorAction
163          */
164         public static ErrorAction ignore_error() {
165                 long ret = bindings.ErrorAction_ignore_error();
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
168                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
169                 return ret_hu_conv;
170         }
171
172         /**
173          * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
174          */
175         public static ErrorAction ignore_and_log(org.ldk.enums.Level a) {
176                 long ret = bindings.ErrorAction_ignore_and_log(a);
177                 Reference.reachabilityFence(a);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
180                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
181                 return ret_hu_conv;
182         }
183
184         /**
185          * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
186          */
187         public static ErrorAction ignore_duplicate_gossip() {
188                 long ret = bindings.ErrorAction_ignore_duplicate_gossip();
189                 if (ret >= 0 && ret <= 4096) { return null; }
190                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
191                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
192                 return ret_hu_conv;
193         }
194
195         /**
196          * Utility method to constructs a new SendErrorMessage-variant ErrorAction
197          */
198         public static ErrorAction send_error_message(ErrorMessage msg) {
199                 long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr & ~1);
200                 Reference.reachabilityFence(msg);
201                 if (ret >= 0 && ret <= 4096) { return null; }
202                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
203                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
204                 return ret_hu_conv;
205         }
206
207         /**
208          * Utility method to constructs a new SendWarningMessage-variant ErrorAction
209          */
210         public static ErrorAction send_warning_message(WarningMessage msg, org.ldk.enums.Level log_level) {
211                 long ret = bindings.ErrorAction_send_warning_message(msg == null ? 0 : msg.ptr & ~1, log_level);
212                 Reference.reachabilityFence(msg);
213                 Reference.reachabilityFence(log_level);
214                 if (ret >= 0 && ret <= 4096) { return null; }
215                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
216                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
217                 return ret_hu_conv;
218         }
219
220 }