Update auto-updated Java files
[ldk-java] / src / main / java / org / ldk / structs / Sha256.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  * SHA-256 hash
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Sha256 extends CommonBase {
16         Sha256(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Sha256_free(ptr); }
21         }
22
23         long clone_ptr() {
24                 long ret = bindings.Sha256_clone_ptr(this.ptr);
25                 Reference.reachabilityFence(this);
26                 return ret;
27         }
28
29         /**
30          * Creates a copy of the Sha256
31          */
32         public Sha256 clone() {
33                 long ret = bindings.Sha256_clone(this.ptr);
34                 Reference.reachabilityFence(this);
35                 if (ret >= 0 && ret <= 4096) { return null; }
36                 Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
37                 ret_hu_conv.ptrs_to.add(this);
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Checks if two Sha256s contain equal inner contents.
43          */
44         public long hash() {
45                 long ret = bindings.Sha256_hash(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         @Override public int hashCode() {
51                 return (int)this.hash();
52         }
53         /**
54          * Checks if two Sha256s contain equal inner contents.
55          * This ignores pointers and is_owned flags and looks at the values in fields.
56          * Two objects with NULL inner values will be considered "equal" here.
57          */
58         public boolean eq(Sha256 b) {
59                 boolean ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
60                 Reference.reachabilityFence(this);
61                 Reference.reachabilityFence(b);
62                 this.ptrs_to.add(b);
63                 return ret;
64         }
65
66         @Override public boolean equals(Object o) {
67                 if (!(o instanceof Sha256)) return false;
68                 return this.eq((Sha256)o);
69         }
70 }