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