Merge pull request #119 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / PositiveTimestamp.java
index 35e09bd01716b889888401240d37849e46d98fe2..03b0cbd1a08ed8865ecec8d2e3fd59c543b2e0bb 100644 (file)
@@ -31,10 +31,10 @@ public class PositiveTimestamp extends CommonBase {
         * Two objects with NULL inner values will be considered "equal" here.
         */
        public boolean eq(PositiveTimestamp b) {
-               boolean ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               boolean ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr);
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(b);
-               this.ptrs_to.add(b);
+               if (this != null) { this.ptrs_to.add(b); };
                return ret;
        }
 
@@ -55,11 +55,23 @@ public class PositiveTimestamp extends CommonBase {
                long ret = bindings.PositiveTimestamp_clone(this.ptr);
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PositiveTimestamp(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               org.ldk.structs.PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PositiveTimestamp(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
+       /**
+        * Checks if two PositiveTimestamps contain equal inner contents.
+        */
+       public long hash() {
+               long ret = bindings.PositiveTimestamp_hash(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       @Override public int hashCode() {
+               return (int)this.hash();
+       }
        /**
         * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`.
         *