[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / Stfu.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 stfu (quiescence) message to be sent by or received from the stfu initiator.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Stfu extends CommonBase {
16         Stfu(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Stfu_free(ptr); }
21         }
22
23         /**
24          * The channel ID where quiescence is intended
25          */
26         public ChannelId get_channel_id() {
27                 long ret = bindings.Stfu_get_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The channel ID where quiescence is intended
37          */
38         public void set_channel_id(org.ldk.structs.ChannelId val) {
39                 bindings.Stfu_set_channel_id(this.ptr, val.ptr);
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42                 if (this != null) { this.ptrs_to.add(val); };
43         }
44
45         /**
46          * Initiator flag, 1 if initiating, 0 if replying to an stfu.
47          */
48         public byte get_initiator() {
49                 byte ret = bindings.Stfu_get_initiator(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * Initiator flag, 1 if initiating, 0 if replying to an stfu.
56          */
57         public void set_initiator(byte val) {
58                 bindings.Stfu_set_initiator(this.ptr, val);
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61         }
62
63         /**
64          * Constructs a new Stfu given each field
65          */
66         public static Stfu of(org.ldk.structs.ChannelId channel_id_arg, byte initiator_arg) {
67                 long ret = bindings.Stfu_new(channel_id_arg.ptr, initiator_arg);
68                 Reference.reachabilityFence(channel_id_arg);
69                 Reference.reachabilityFence(initiator_arg);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.Stfu ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Stfu(null, ret); }
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
74                 return ret_hu_conv;
75         }
76
77         long clone_ptr() {
78                 long ret = bindings.Stfu_clone_ptr(this.ptr);
79                 Reference.reachabilityFence(this);
80                 return ret;
81         }
82
83         /**
84          * Creates a copy of the Stfu
85          */
86         public Stfu clone() {
87                 long ret = bindings.Stfu_clone(this.ptr);
88                 Reference.reachabilityFence(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.Stfu ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Stfu(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Checks if two Stfus contain equal inner contents.
97          * This ignores pointers and is_owned flags and looks at the values in fields.
98          * Two objects with NULL inner values will be considered "equal" here.
99          */
100         public boolean eq(org.ldk.structs.Stfu b) {
101                 boolean ret = bindings.Stfu_eq(this.ptr, b.ptr);
102                 Reference.reachabilityFence(this);
103                 Reference.reachabilityFence(b);
104                 if (this != null) { this.ptrs_to.add(b); };
105                 return ret;
106         }
107
108         @Override public boolean equals(Object o) {
109                 if (!(o instanceof Stfu)) return false;
110                 return this.eq((Stfu)o);
111         }
112         /**
113          * Serialize the Stfu object into a byte array which can be read by Stfu_read
114          */
115         public byte[] write() {
116                 byte[] ret = bindings.Stfu_write(this.ptr);
117                 Reference.reachabilityFence(this);
118                 return ret;
119         }
120
121         /**
122          * Read a Stfu from a byte array, created by Stfu_write
123          */
124         public static Result_StfuDecodeErrorZ read(byte[] ser) {
125                 long ret = bindings.Stfu_read(ser);
126                 Reference.reachabilityFence(ser);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 Result_StfuDecodeErrorZ ret_hu_conv = Result_StfuDecodeErrorZ.constr_from_ptr(ret);
129                 return ret_hu_conv;
130         }
131
132 }