[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / java / org / ldk / structs / ExpiryTime.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  * Positive duration that defines when (relatively to the timestamp) in the future the invoice
13  * expires
14  */
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 {
20                 super.finalize();
21                 if (ptr != 0) { bindings.ExpiryTime_free(ptr); }
22         }
23
24         long clone_ptr() {
25                 long ret = bindings.ExpiryTime_clone_ptr(this.ptr);
26                 Reference.reachabilityFence(this);
27                 return ret;
28         }
29
30         /**
31          * Creates a copy of the ExpiryTime
32          */
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                 ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ExpiryTime(null, ret); }
38                 ret_hu_conv.ptrs_to.add(this);
39                 return ret_hu_conv;
40         }
41
42         /**
43          * Checks if two ExpiryTimes contain equal inner contents.
44          */
45         public long hash() {
46                 long ret = bindings.ExpiryTime_hash(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         @Override public int hashCode() {
52                 return (int)this.hash();
53         }
54         /**
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.
58          */
59         public boolean eq(ExpiryTime b) {
60                 boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(b);
63                 this.ptrs_to.add(b);
64                 return ret;
65         }
66
67         @Override public boolean equals(Object o) {
68                 if (!(o instanceof ExpiryTime)) return false;
69                 return this.eq((ExpiryTime)o);
70         }
71         /**
72          * Construct an `ExpiryTime` from seconds.
73          */
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                 ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ExpiryTime(null, ret); }
79                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Construct an `ExpiryTime` from a `Duration`.
85          */
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                 ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ExpiryTime(null, ret); }
91                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Returns the expiry time in seconds
97          */
98         public long as_seconds() {
99                 long ret = bindings.ExpiryTime_as_seconds(this.ptr);
100                 Reference.reachabilityFence(this);
101                 return ret;
102         }
103
104         /**
105          * Returns a reference to the underlying `Duration` (=expiry time)
106          */
107         public long as_duration() {
108                 long ret = bindings.ExpiryTime_as_duration(this.ptr);
109                 Reference.reachabilityFence(this);
110                 return ret;
111         }
112
113 }