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 * Positive duration that defines when (relatively to the timestamp) in the future the invoice
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class ExpiryTime extends CommonBase {
17 ExpiryTime(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.ExpiryTime_free(ptr); }
25 long ret = bindings.ExpiryTime_clone_ptr(this.ptr);
26 Reference.reachabilityFence(this);
31 * Creates a copy of the ExpiryTime
33 public ExpiryTime clone() {
34 long ret = bindings.ExpiryTime_clone(this.ptr);
35 Reference.reachabilityFence(this);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
43 * Checks if two ExpiryTimes contain equal inner contents.
46 long ret = bindings.ExpiryTime_hash(this.ptr);
47 Reference.reachabilityFence(this);
51 @Override public int hashCode() {
52 return (int)this.hash();
55 * Checks if two ExpiryTimes contain equal inner contents.
56 * This ignores pointers and is_owned flags and looks at the values in fields.
57 * Two objects with NULL inner values will be considered "equal" here.
59 public boolean eq(ExpiryTime b) {
60 boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(b);
63 if (this != null) { this.ptrs_to.add(b); };
67 @Override public boolean equals(Object o) {
68 if (!(o instanceof ExpiryTime)) return false;
69 return this.eq((ExpiryTime)o);
72 * Construct an `ExpiryTime` from seconds.
74 public static ExpiryTime from_seconds(long seconds) {
75 long ret = bindings.ExpiryTime_from_seconds(seconds);
76 Reference.reachabilityFence(seconds);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
84 * Construct an `ExpiryTime` from a `Duration`.
86 public static ExpiryTime from_duration(long duration) {
87 long ret = bindings.ExpiryTime_from_duration(duration);
88 Reference.reachabilityFence(duration);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
96 * Returns the expiry time in seconds
98 public long as_seconds() {
99 long ret = bindings.ExpiryTime_as_seconds(this.ptr);
100 Reference.reachabilityFence(this);
105 * Returns a reference to the underlying `Duration` (=expiry time)
107 public long as_duration() {
108 long ret = bindings.ExpiryTime_as_duration(this.ptr);
109 Reference.reachabilityFence(this);