[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / Description.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  * Description string
13  * 
14  * # Invariants
15  * The description can be at most 639 __bytes__ long
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class Description extends CommonBase {
19         Description(Object _dummy, long ptr) { super(ptr); }
20         @Override @SuppressWarnings("deprecation")
21         protected void finalize() throws Throwable {
22                 super.finalize();
23                 if (ptr != 0) { bindings.Description_free(ptr); }
24         }
25
26         long clone_ptr() {
27                 long ret = bindings.Description_clone_ptr(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * Creates a copy of the Description
34          */
35         public Description clone() {
36                 long ret = bindings.Description_clone(this.ptr);
37                 Reference.reachabilityFence(this);
38                 if (ret >= 0 && ret <= 4096) { return null; }
39                 org.ldk.structs.Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Description(null, ret); }
40                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
41                 return ret_hu_conv;
42         }
43
44         /**
45          * Generates a non-cryptographic 64-bit hash of the Description.
46          */
47         public long hash() {
48                 long ret = bindings.Description_hash(this.ptr);
49                 Reference.reachabilityFence(this);
50                 return ret;
51         }
52
53         @Override public int hashCode() {
54                 return (int)this.hash();
55         }
56         /**
57          * Checks if two Descriptions contain equal inner contents.
58          * This ignores pointers and is_owned flags and looks at the values in fields.
59          * Two objects with NULL inner values will be considered "equal" here.
60          */
61         public boolean eq(org.ldk.structs.Description b) {
62                 boolean ret = bindings.Description_eq(this.ptr, b == null ? 0 : b.ptr);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(b);
65                 if (this != null) { this.ptrs_to.add(b); };
66                 return ret;
67         }
68
69         @Override public boolean equals(Object o) {
70                 if (!(o instanceof Description)) return false;
71                 return this.eq((Description)o);
72         }
73         /**
74          * Creates a new `Description` if `description` is at most 1023 __bytes__ long,
75          * returns [`CreationError::DescriptionTooLong`] otherwise
76          * 
77          * Please note that single characters may use more than one byte due to UTF8 encoding.
78          */
79         public static Result_DescriptionCreationErrorZ of(java.lang.String description) {
80                 long ret = bindings.Description_new(description);
81                 Reference.reachabilityFence(description);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 Result_DescriptionCreationErrorZ ret_hu_conv = Result_DescriptionCreationErrorZ.constr_from_ptr(ret);
84                 return ret_hu_conv;
85         }
86
87         /**
88          * Returns the underlying description [`UntrustedString`]
89          */
90         public UntrustedString into_inner() {
91                 long ret = bindings.Description_into_inner(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96                 if (this != null) { this.ptrs_to.add(this); };
97                 return ret_hu_conv;
98         }
99
100         /**
101          * Get the string representation of a Description object
102          */
103         public String to_str() {
104                 String ret = bindings.Description_to_str(this.ptr);
105                 Reference.reachabilityFence(this);
106                 return ret;
107         }
108
109 }