Merge pull request #120 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / UnsignedChannelUpdate.java
index fc6d0b6596b9b53f9ef6f97fefba7941871eec43..7805cc07b208ec45311ac3105d1bdebdc72b713e 100644 (file)
@@ -237,7 +237,7 @@ public class UnsignedChannelUpdate extends CommonBase {
                Reference.reachabilityFence(excess_data_arg);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -255,10 +255,27 @@ public class UnsignedChannelUpdate extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
+       /**
+        * Checks if two UnsignedChannelUpdates contain equal inner contents.
+        * This ignores pointers and is_owned flags and looks at the values in fields.
+        * Two objects with NULL inner values will be considered "equal" here.
+        */
+       public boolean eq(UnsignedChannelUpdate b) {
+               boolean ret = bindings.UnsignedChannelUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(b);
+               if (this != null) { this.ptrs_to.add(b); };
+               return ret;
+       }
+
+       @Override public boolean equals(Object o) {
+               if (!(o instanceof UnsignedChannelUpdate)) return false;
+               return this.eq((UnsignedChannelUpdate)o);
+       }
        /**
         * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
         */