Update java bindings with new generator and new upstream code
[ldk-java] / src / main / java / org / ldk / structs / UnsignedNodeAnnouncement.java
index adee1f6653b70ba742079136bc24ed18014256c9..27e4dac77c6546c51c17d36bf56974b517406fb4 100644 (file)
@@ -2,75 +2,137 @@ package org.ldk.structs;
 
 import org.ldk.impl.bindings;
 import org.ldk.enums.*;
+import org.ldk.util.*;
+import java.util.Arrays;
 
+
+/**
+ * The unsigned part of a node_announcement
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class UnsignedNodeAnnouncement extends CommonBase {
        UnsignedNodeAnnouncement(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
                super.finalize();
-               bindings.UnsignedNodeAnnouncement_free(ptr);
+               if (ptr != 0) { bindings.UnsignedNodeAnnouncement_free(ptr); }
        }
 
-       public UnsignedNodeAnnouncement(UnsignedNodeAnnouncement orig) {
-               super(bindings.UnsignedNodeAnnouncement_clone(orig == null ? 0 : orig.ptr & ~1));
-               this.ptrs_to.add(orig);
+       /**
+        * The advertised features
+        */
+       public NodeFeatures get_features() {
+               long ret = bindings.UnsignedNodeAnnouncement_get_features(this.ptr);
+               NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
        }
 
-       public NodeFeatures get_features(UnsignedNodeAnnouncement this_ptr) {
-               NodeFeatures ret = new NodeFeatures(null, bindings.UnsignedNodeAnnouncement_get_features(this_ptr == null ? 0 : this_ptr.ptr & ~1));
-               this.ptrs_to.add(this_ptr);
-               return ret;
+       /**
+        * The advertised features
+        */
+       public void set_features(NodeFeatures val) {
+               bindings.UnsignedNodeAnnouncement_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
+               this.ptrs_to.add(val);
        }
 
-       // Skipped UnsignedNodeAnnouncement_set_features
-       public int get_timestamp(UnsignedNodeAnnouncement this_ptr) {
-               int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * A strictly monotonic announcement counter, with gaps allowed
+        */
+       public int get_timestamp() {
+               int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr);
                return ret;
        }
 
-       public void set_timestamp(UnsignedNodeAnnouncement this_ptr, int val) {
-               bindings.UnsignedNodeAnnouncement_set_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * A strictly monotonic announcement counter, with gaps allowed
+        */
+       public void set_timestamp(int val) {
+               bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val);
        }
 
-       public byte[] get_node_id(UnsignedNodeAnnouncement this_ptr) {
-               byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The node_id this announcement originated from (don't rebroadcast the node_announcement back
+        * to this node).
+        */
+       public byte[] get_node_id() {
+               byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr);
                return ret;
        }
 
-       public void set_node_id(UnsignedNodeAnnouncement this_ptr, byte[] val) {
-               bindings.UnsignedNodeAnnouncement_set_node_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The node_id this announcement originated from (don't rebroadcast the node_announcement back
+        * to this node).
+        */
+       public void set_node_id(byte[] val) {
+               bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, val);
        }
 
-       public byte[] get_rgb(UnsignedNodeAnnouncement this_ptr) {
-               byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * An RGB color for UI purposes
+        */
+       public byte[] get_rgb() {
+               byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
                return ret;
        }
 
-       public void set_rgb(UnsignedNodeAnnouncement this_ptr, byte[] val) {
-               bindings.UnsignedNodeAnnouncement_set_rgb(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * An RGB color for UI purposes
+        */
+       public void set_rgb(byte[] val) {
+               bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, val);
        }
 
-       public byte[] get_alias(UnsignedNodeAnnouncement this_ptr) {
-               byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
+        * of uniqueness.
+        */
+       public byte[] get_alias() {
+               byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr);
                return ret;
        }
 
-       public void set_alias(UnsignedNodeAnnouncement this_ptr, byte[] val) {
-               bindings.UnsignedNodeAnnouncement_set_alias(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
+        * of uniqueness.
+        */
+       public void set_alias(byte[] val) {
+               bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, val);
+       }
+
+       /**
+        * List of addresses on which this node is reachable
+        */
+       public void set_addresses(NetAddress[] val) {
+               bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray());
+               /* TODO 2 NetAddress  */;
+       }
+
+       /**
+        * Creates a copy of the UnsignedNodeAnnouncement
+        */
+       public UnsignedNodeAnnouncement clone() {
+               long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
+               UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
+               return ret;
        }
 
-       // Skipped UnsignedNodeAnnouncement_set_addresses
-       // Skipped UnsignedNodeAnnouncement_write
-       public UnsignedNodeAnnouncement(byte[] ser) {
-               super(bindings.UnsignedNodeAnnouncement_read(ser));
+       /**
+        * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
+        */
+       public static Result_UnsignedNodeAnnouncementDecodeErrorZ constructor_read(byte[] ser) {
+               long ret = bindings.UnsignedNodeAnnouncement_read(ser);
+               Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
        }
 
 }