1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Features used within an `init` message.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class InitFeatures extends CommonBase {
16 InitFeatures(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.InitFeatures_free(ptr); }
24 * Checks if two InitFeaturess contain equal inner contents.
25 * This ignores pointers and is_owned flags and looks at the values in fields.
26 * Two objects with NULL inner values will be considered "equal" here.
28 public boolean eq(InitFeatures b) {
29 boolean ret = bindings.InitFeatures_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
30 Reference.reachabilityFence(this);
31 Reference.reachabilityFence(b);
36 @Override public boolean equals(Object o) {
37 if (!(o instanceof InitFeatures)) return false;
38 return this.eq((InitFeatures)o);
41 long ret = bindings.InitFeatures_clone_ptr(this.ptr);
42 Reference.reachabilityFence(this);
47 * Creates a copy of the InitFeatures
49 public InitFeatures clone() {
50 long ret = bindings.InitFeatures_clone(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
54 ret_hu_conv.ptrs_to.add(this);
59 * Create a blank Features with no features set
61 public static InitFeatures empty() {
62 long ret = bindings.InitFeatures_empty();
63 if (ret >= 0 && ret <= 4096) { return null; }
64 InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
65 ret_hu_conv.ptrs_to.add(ret_hu_conv);
70 * Creates a Features with the bits set which are known by the implementation
72 public static InitFeatures known() {
73 long ret = bindings.InitFeatures_known();
74 if (ret >= 0 && ret <= 4096) { return null; }
75 InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
76 ret_hu_conv.ptrs_to.add(ret_hu_conv);
81 * Returns true if this `Features` object contains unknown feature flags which are set as
84 public boolean requires_unknown_bits() {
85 boolean ret = bindings.InitFeatures_requires_unknown_bits(this.ptr);
86 Reference.reachabilityFence(this);
91 * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read
93 public byte[] write() {
94 byte[] ret = bindings.InitFeatures_write(this.ptr);
95 Reference.reachabilityFence(this);
100 * Read a InitFeatures from a byte array, created by InitFeatures_write
102 public static Result_InitFeaturesDecodeErrorZ read(byte[] ser) {
103 long ret = bindings.InitFeatures_read(ser);
104 Reference.reachabilityFence(ser);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 Result_InitFeaturesDecodeErrorZ ret_hu_conv = Result_InitFeaturesDecodeErrorZ.constr_from_ptr(ret);