Update auto-generated bindings to 0.0.103
[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 javax.annotation.Nullable;
8
9
10 /**
11  * Used to put an error message in a LightningError
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ErrorAction extends CommonBase {
15         private ErrorAction(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ErrorAction_free(ptr); }
20         }
21         static ErrorAction constr_from_ptr(long ptr) {
22                 bindings.LDKErrorAction raw_val = bindings.LDKErrorAction_ref_from_ptr(ptr);
23                 if (raw_val.getClass() == bindings.LDKErrorAction.DisconnectPeer.class) {
24                         return new DisconnectPeer(ptr, (bindings.LDKErrorAction.DisconnectPeer)raw_val);
25                 }
26                 if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreError.class) {
27                         return new IgnoreError(ptr, (bindings.LDKErrorAction.IgnoreError)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreAndLog.class) {
30                         return new IgnoreAndLog(ptr, (bindings.LDKErrorAction.IgnoreAndLog)raw_val);
31                 }
32                 if (raw_val.getClass() == bindings.LDKErrorAction.SendErrorMessage.class) {
33                         return new SendErrorMessage(ptr, (bindings.LDKErrorAction.SendErrorMessage)raw_val);
34                 }
35                 assert false; return null; // Unreachable without extending the (internal) bindings interface
36         }
37
38         public final static class DisconnectPeer extends ErrorAction {
39                 /**
40                  * An error message which we should make an effort to send before we disconnect.
41                  * 
42                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
43                 */
44                 @Nullable public final ErrorMessage msg;
45                 private DisconnectPeer(long ptr, bindings.LDKErrorAction.DisconnectPeer obj) {
46                         super(null, ptr);
47                         long msg = obj.msg;
48                         ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); }
49                         msg_hu_conv.ptrs_to.add(this);
50                         this.msg = msg_hu_conv;
51                 }
52         }
53         public final static class IgnoreError extends ErrorAction {
54                 private IgnoreError(long ptr, bindings.LDKErrorAction.IgnoreError obj) {
55                         super(null, ptr);
56                 }
57         }
58         public final static class IgnoreAndLog extends ErrorAction {
59                 public final Level ignore_and_log;
60                 private IgnoreAndLog(long ptr, bindings.LDKErrorAction.IgnoreAndLog obj) {
61                         super(null, ptr);
62                         this.ignore_and_log = obj.ignore_and_log;
63                 }
64         }
65         public final static class SendErrorMessage extends ErrorAction {
66                 /**
67                  * The message to send.
68                 */
69                 public final ErrorMessage msg;
70                 private SendErrorMessage(long ptr, bindings.LDKErrorAction.SendErrorMessage obj) {
71                         super(null, ptr);
72                         long msg = obj.msg;
73                         ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); }
74                         msg_hu_conv.ptrs_to.add(this);
75                         this.msg = msg_hu_conv;
76                 }
77         }
78         /**
79          * Creates a copy of the ErrorAction
80          */
81         public ErrorAction clone() {
82                 long ret = bindings.ErrorAction_clone(this.ptr);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
85                 ret_hu_conv.ptrs_to.add(this);
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Utility method to constructs a new DisconnectPeer-variant ErrorAction
91          */
92         public static ErrorAction disconnect_peer(ErrorMessage msg) {
93                 long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr & ~1);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
96                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
97                 return ret_hu_conv;
98         }
99
100         /**
101          * Utility method to constructs a new IgnoreError-variant ErrorAction
102          */
103         public static ErrorAction ignore_error() {
104                 long ret = bindings.ErrorAction_ignore_error();
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
107                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
113          */
114         public static ErrorAction ignore_and_log(org.ldk.enums.Level a) {
115                 long ret = bindings.ErrorAction_ignore_and_log(a);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
118                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Utility method to constructs a new SendErrorMessage-variant ErrorAction
124          */
125         public static ErrorAction send_error_message(ErrorMessage msg) {
126                 long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr & ~1);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
129                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
130                 return ret_hu_conv;
131         }
132
133 }