Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / PositiveTimestamp.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  * A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX
12  * timestamp is positive.
13  * 
14  * # Invariants
15  * The UNIX timestamp representing the stored time has to be positive and small enough so that
16  * a `EpiryTime` can be added to it without an overflow.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class PositiveTimestamp extends CommonBase {
20         PositiveTimestamp(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.PositiveTimestamp_free(ptr); }
25         }
26
27         /**
28          * Checks if two PositiveTimestamps 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(PositiveTimestamp b) {
33                 boolean ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
34                 this.ptrs_to.add(b);
35                 return ret;
36         }
37
38         long clone_ptr() {
39                 long ret = bindings.PositiveTimestamp_clone_ptr(this.ptr);
40                 return ret;
41         }
42
43         /**
44          * Creates a copy of the PositiveTimestamp
45          */
46         public PositiveTimestamp clone() {
47                 long ret = bindings.PositiveTimestamp_clone(this.ptr);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PositiveTimestamp(null, ret); }
50                 ret_hu_conv.ptrs_to.add(this);
51                 return ret_hu_conv;
52         }
53
54         /**
55          * Create a new `PositiveTimestamp` from a unix timestamp in the Range
56          * `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a
57          * `CreationError::TimestampOutOfBounds`.
58          */
59         public static Result_PositiveTimestampCreationErrorZ from_unix_timestamp(long unix_seconds) {
60                 long ret = bindings.PositiveTimestamp_from_unix_timestamp(unix_seconds);
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
63                 return ret_hu_conv;
64         }
65
66         /**
67          * Create a new `PositiveTimestamp` from a `SystemTime` with a corresponding unix timestamp in
68          * the Range `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a
69          * `CreationError::TimestampOutOfBounds`.
70          */
71         public static Result_PositiveTimestampCreationErrorZ from_system_time(long time) {
72                 long ret = bindings.PositiveTimestamp_from_system_time(time);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Returns the UNIX timestamp representing the stored time
80          */
81         public long as_unix_timestamp() {
82                 long ret = bindings.PositiveTimestamp_as_unix_timestamp(this.ptr);
83                 return ret;
84         }
85
86         /**
87          * Returns a reference to the internal `SystemTime` time representation
88          */
89         public long as_time() {
90                 long ret = bindings.PositiveTimestamp_as_time(this.ptr);
91                 return ret;
92         }
93
94 }