Only handle `null` objects when its allowed
[ldk-java] / src / main / java / org / ldk / structs / ReplyChannelRange.java
index ce08c8a8305934d5a9464bd3c3f601ff6b4d358f..10ca61a3c511c876873c1c270abd9791d23b9288 100644 (file)
@@ -9,13 +9,17 @@ import javax.annotation.Nullable;
 
 
 /**
- * A reply_channel_range message is a reply to a query_channel_range
- * message. Multiple reply_channel_range messages can be sent in reply
- * to a single query_channel_range message. The query recipient makes a
+ * A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
+ * message.
+ * 
+ * Multiple `reply_channel_range` messages can be sent in reply
+ * to a single [`QueryChannelRange`] message. The query recipient makes a
  * best effort to respond based on their local network view which may
- * not be a perfect view of the network. The short_channel_ids in the
- * reply are encoded. We only support encoding_type=0 uncompressed
- * serialization and do not support encoding_type=1 zlib serialization.
+ * not be a perfect view of the network. The `short_channel_id`s in the
+ * reply are encoded. We only support `encoding_type=0` uncompressed
+ * serialization and do not support `encoding_type=1` zlib serialization.
+ * 
+ * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
  */
 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class ReplyChannelRange extends CommonBase {
@@ -99,7 +103,18 @@ public class ReplyChannelRange extends CommonBase {
        }
 
        /**
-        * The short_channel_ids in the channel range
+        * The `short_channel_id`s in the channel range
+        * 
+        * Returns a copy of the field.
+        */
+       public long[] get_short_channel_ids() {
+               long[] ret = bindings.ReplyChannelRange_get_short_channel_ids(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * The `short_channel_id`s in the channel range
         */
        public void set_short_channel_ids(long[] val) {
                bindings.ReplyChannelRange_set_short_channel_ids(this.ptr, val);
@@ -119,7 +134,7 @@ public class ReplyChannelRange extends CommonBase {
                Reference.reachabilityFence(short_channel_ids_arg);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyChannelRange(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;
        }
 
@@ -137,10 +152,39 @@ public class ReplyChannelRange extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReplyChannelRange(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;
        }
 
+       /**
+        * Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
+        */
+       public long hash() {
+               long ret = bindings.ReplyChannelRange_hash(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       @Override public int hashCode() {
+               return (int)this.hash();
+       }
+       /**
+        * Checks if two ReplyChannelRanges 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(org.ldk.structs.ReplyChannelRange b) {
+               boolean ret = bindings.ReplyChannelRange_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 ReplyChannelRange)) return false;
+               return this.eq((ReplyChannelRange)o);
+       }
        /**
         * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
         */