[Java] Update auto-generated bindings to 0.0.105.0
[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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A timestamp that refers to a date after 1 January 1970.
13  * 
14  * # Invariants
15  * 
16  * The Unix timestamp representing the stored time has to be positive and no greater than
17  * [`MAX_TIMESTAMP`].
18  */
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class PositiveTimestamp extends CommonBase {
21         PositiveTimestamp(Object _dummy, long ptr) { super(ptr); }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 super.finalize();
25                 if (ptr != 0) { bindings.PositiveTimestamp_free(ptr); }
26         }
27
28         /**
29          * Checks if two PositiveTimestamps 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(PositiveTimestamp b) {
34                 boolean ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
35                 Reference.reachabilityFence(this);
36                 Reference.reachabilityFence(b);
37                 this.ptrs_to.add(b);
38                 return ret;
39         }
40
41         @Override public boolean equals(Object o) {
42                 if (!(o instanceof PositiveTimestamp)) return false;
43                 return this.eq((PositiveTimestamp)o);
44         }
45         long clone_ptr() {
46                 long ret = bindings.PositiveTimestamp_clone_ptr(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         /**
52          * Creates a copy of the PositiveTimestamp
53          */
54         public PositiveTimestamp clone() {
55                 long ret = bindings.PositiveTimestamp_clone(this.ptr);
56                 Reference.reachabilityFence(this);
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PositiveTimestamp(null, ret); }
59                 ret_hu_conv.ptrs_to.add(this);
60                 return ret_hu_conv;
61         }
62
63         /**
64          * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`.
65          * 
66          * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
67          */
68         public static Result_PositiveTimestampCreationErrorZ from_unix_timestamp(long unix_seconds) {
69                 long ret = bindings.PositiveTimestamp_from_unix_timestamp(unix_seconds);
70                 Reference.reachabilityFence(unix_seconds);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in
78          * the range `0..=MAX_TIMESTAMP`.
79          * 
80          * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
81          */
82         public static Result_PositiveTimestampCreationErrorZ from_system_time(long time) {
83                 long ret = bindings.PositiveTimestamp_from_system_time(time);
84                 Reference.reachabilityFence(time);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range
92          * `0..=MAX_TIMESTAMP`.
93          * 
94          * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
95          */
96         public static Result_PositiveTimestampCreationErrorZ from_duration_since_epoch(long duration) {
97                 long ret = bindings.PositiveTimestamp_from_duration_since_epoch(duration);
98                 Reference.reachabilityFence(duration);
99                 if (ret >= 0 && ret <= 4096) { return null; }
100                 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Returns the Unix timestamp representing the stored time
106          */
107         public long as_unix_timestamp() {
108                 long ret = bindings.PositiveTimestamp_as_unix_timestamp(this.ptr);
109                 Reference.reachabilityFence(this);
110                 return ret;
111         }
112
113         /**
114          * Returns the duration of the stored time since the Unix epoch
115          */
116         public long as_duration_since_epoch() {
117                 long ret = bindings.PositiveTimestamp_as_duration_since_epoch(this.ptr);
118                 Reference.reachabilityFence(this);
119                 return ret;
120         }
121
122         /**
123          * Returns the [`SystemTime`] representing the stored time
124          */
125         public long as_time() {
126                 long ret = bindings.PositiveTimestamp_as_time(this.ptr);
127                 Reference.reachabilityFence(this);
128                 return ret;
129         }
130
131 }