Merge pull request #56 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / LightningError.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  * An Err type for failure to process messages.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class LightningError extends CommonBase {
15         LightningError(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.LightningError_free(ptr); }
20         }
21
22         /**
23          * A human-readable message describing the error
24          */
25         public String get_err() {
26                 String ret = bindings.LightningError_get_err(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * A human-readable message describing the error
32          */
33         public void set_err(java.lang.String val) {
34                 bindings.LightningError_set_err(this.ptr, val);
35         }
36
37         /**
38          * The action which should be taken against the offending peer.
39          */
40         public ErrorAction get_action() {
41                 long ret = bindings.LightningError_get_action(this.ptr);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
44                 ret_hu_conv.ptrs_to.add(this);
45                 return ret_hu_conv;
46         }
47
48         /**
49          * The action which should be taken against the offending peer.
50          */
51         public void set_action(ErrorAction val) {
52                 bindings.LightningError_set_action(this.ptr, val.ptr);
53         }
54
55         /**
56          * Constructs a new LightningError given each field
57          */
58         public static LightningError of(java.lang.String err_arg, ErrorAction action_arg) {
59                 long ret = bindings.LightningError_new(err_arg, action_arg.ptr);
60                 if (ret >= 0 && ret <= 4096) { return null; }
61                 LightningError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new LightningError(null, ret); }
62                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
63                 return ret_hu_conv;
64         }
65
66         long clone_ptr() {
67                 long ret = bindings.LightningError_clone_ptr(this.ptr);
68                 return ret;
69         }
70
71         /**
72          * Creates a copy of the LightningError
73          */
74         public LightningError clone() {
75                 long ret = bindings.LightningError_clone(this.ptr);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 LightningError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new LightningError(null, ret); }
78                 ret_hu_conv.ptrs_to.add(this);
79                 return ret_hu_conv;
80         }
81
82 }