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