[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / Hostname.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  * Represents a hostname for serialization purposes.
13  * Only the character set and length will be validated.
14  * The character set consists of ASCII alphanumeric characters, hyphens, and periods.
15  * Its length is guaranteed to be representable by a single byte.
16  * This serialization is used by [`BOLT 7`] hostnames.
17  * 
18  * [`BOLT 7`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md
19  */
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class Hostname extends CommonBase {
22         Hostname(Object _dummy, long ptr) { super(ptr); }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 super.finalize();
26                 if (ptr != 0) { bindings.Hostname_free(ptr); }
27         }
28
29         long clone_ptr() {
30                 long ret = bindings.Hostname_clone_ptr(this.ptr);
31                 Reference.reachabilityFence(this);
32                 return ret;
33         }
34
35         /**
36          * Creates a copy of the Hostname
37          */
38         public Hostname clone() {
39                 long ret = bindings.Hostname_clone(this.ptr);
40                 Reference.reachabilityFence(this);
41                 if (ret >= 0 && ret <= 4096) { return null; }
42                 org.ldk.structs.Hostname ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Hostname(null, ret); }
43                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
44                 return ret_hu_conv;
45         }
46
47         /**
48          * Generates a non-cryptographic 64-bit hash of the Hostname.
49          */
50         public long hash() {
51                 long ret = bindings.Hostname_hash(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         @Override public int hashCode() {
57                 return (int)this.hash();
58         }
59         /**
60          * Checks if two Hostnames contain equal inner contents.
61          * This ignores pointers and is_owned flags and looks at the values in fields.
62          * Two objects with NULL inner values will be considered "equal" here.
63          */
64         public boolean eq(org.ldk.structs.Hostname b) {
65                 boolean ret = bindings.Hostname_eq(this.ptr, b == null ? 0 : b.ptr);
66                 Reference.reachabilityFence(this);
67                 Reference.reachabilityFence(b);
68                 if (this != null) { this.ptrs_to.add(b); };
69                 return ret;
70         }
71
72         @Override public boolean equals(Object o) {
73                 if (!(o instanceof Hostname)) return false;
74                 return this.eq((Hostname)o);
75         }
76         /**
77          * Returns the length of the hostname.
78          */
79         public byte len() {
80                 byte ret = bindings.Hostname_len(this.ptr);
81                 Reference.reachabilityFence(this);
82                 return ret;
83         }
84
85         /**
86          * Serialize the Hostname object into a byte array which can be read by Hostname_read
87          */
88         public byte[] write() {
89                 byte[] ret = bindings.Hostname_write(this.ptr);
90                 Reference.reachabilityFence(this);
91                 return ret;
92         }
93
94         /**
95          * Read a Hostname from a byte array, created by Hostname_write
96          */
97         public static Result_HostnameDecodeErrorZ read(byte[] ser) {
98                 long ret = bindings.Hostname_read(ser);
99                 Reference.reachabilityFence(ser);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 Result_HostnameDecodeErrorZ ret_hu_conv = Result_HostnameDecodeErrorZ.constr_from_ptr(ret);
102                 return ret_hu_conv;
103         }
104
105 }