Update auto-generated bindings
[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
8
9 /**
10  * Positive duration that defines when (relatively to the timestamp) in the future the invoice
11  * expires
12  * 
13  * # Invariants
14  * The number of seconds this expiry time represents has to be in the range
15  * `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
16  * timestamp
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class ExpiryTime extends CommonBase {
20         ExpiryTime(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.ExpiryTime_free(ptr); }
25         }
26
27         /**
28          * Checks if two ExpiryTimes contain equal inner contents.
29          * This ignores pointers and is_owned flags and looks at the values in fields.
30          * Two objects with NULL inner values will be considered "equal" here.
31          */
32         public boolean eq(ExpiryTime b) {
33                 boolean ret = bindings.ExpiryTime_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
34                 this.ptrs_to.add(b);
35                 return ret;
36         }
37
38         /**
39          * Creates a copy of the ExpiryTime
40          */
41         public ExpiryTime clone() {
42                 long ret = bindings.ExpiryTime_clone(this.ptr);
43                 if (ret < 1024) { return null; }
44                 ExpiryTime ret_hu_conv = new ExpiryTime(null, ret);
45                 ret_hu_conv.ptrs_to.add(this);
46                 return ret_hu_conv;
47         }
48
49         /**
50          * Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would
51          * overflow on adding the `EpiryTime` to it then this function will return a
52          * `CreationError::ExpiryTimeOutOfBounds`.
53          */
54         public static Result_ExpiryTimeCreationErrorZ from_seconds(long seconds) {
55                 long ret = bindings.ExpiryTime_from_seconds(seconds);
56                 if (ret < 1024) { return null; }
57                 Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which
63          * would overflow on adding the `EpiryTime` to it then this function will return a
64          * `CreationError::ExpiryTimeOutOfBounds`.
65          */
66         public static Result_ExpiryTimeCreationErrorZ from_duration(long duration) {
67                 long ret = bindings.ExpiryTime_from_duration(duration);
68                 if (ret < 1024) { return null; }
69                 Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Returns the expiry time in seconds
75          */
76         public long as_seconds() {
77                 long ret = bindings.ExpiryTime_as_seconds(this.ptr);
78                 return ret;
79         }
80
81         /**
82          * Returns a reference to the underlying `Duration` (=expiry time)
83          */
84         public long as_duration() {
85                 long ret = bindings.ExpiryTime_as_duration(this.ptr);
86                 return ret;
87         }
88
89 }