[Java] Update auto-generated Java bindings for 0.0.113
[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                         org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
59                         if (msg_hu_conv != null) { 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                         org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
104                         if (msg_hu_conv != null) { 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                         org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); }
126                         if (msg_hu_conv != null) { 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                 if (ret_hu_conv != null) { 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(org.ldk.structs.ErrorMessage msg) {
153                 long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr);
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                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
159                 return ret_hu_conv;
160         }
161
162         /**
163          * Utility method to constructs a new IgnoreError-variant ErrorAction
164          */
165         public static ErrorAction ignore_error() {
166                 long ret = bindings.ErrorAction_ignore_error();
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
169                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
170                 return ret_hu_conv;
171         }
172
173         /**
174          * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
175          */
176         public static ErrorAction ignore_and_log(org.ldk.enums.Level a) {
177                 long ret = bindings.ErrorAction_ignore_and_log(a);
178                 Reference.reachabilityFence(a);
179                 if (ret >= 0 && ret <= 4096) { return null; }
180                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
181                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
182                 return ret_hu_conv;
183         }
184
185         /**
186          * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
187          */
188         public static ErrorAction ignore_duplicate_gossip() {
189                 long ret = bindings.ErrorAction_ignore_duplicate_gossip();
190                 if (ret >= 0 && ret <= 4096) { return null; }
191                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
192                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
193                 return ret_hu_conv;
194         }
195
196         /**
197          * Utility method to constructs a new SendErrorMessage-variant ErrorAction
198          */
199         public static ErrorAction send_error_message(org.ldk.structs.ErrorMessage msg) {
200                 long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr);
201                 Reference.reachabilityFence(msg);
202                 if (ret >= 0 && ret <= 4096) { return null; }
203                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
204                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
205                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
206                 return ret_hu_conv;
207         }
208
209         /**
210          * Utility method to constructs a new SendWarningMessage-variant ErrorAction
211          */
212         public static ErrorAction send_warning_message(org.ldk.structs.WarningMessage msg, org.ldk.enums.Level log_level) {
213                 long ret = bindings.ErrorAction_send_warning_message(msg == null ? 0 : msg.ptr, log_level);
214                 Reference.reachabilityFence(msg);
215                 Reference.reachabilityFence(log_level);
216                 if (ret >= 0 && ret <= 4096) { return null; }
217                 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
218                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
219                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); };
220                 return ret_hu_conv;
221         }
222
223 }