[Java] Update auto-generated Java bindings for 0.0.113
[ldk-java] / src / main / java / org / ldk / structs / Destination.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  * The destination of an onion message.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Destination extends CommonBase {
16         private Destination(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Destination_free(ptr); }
21         }
22         static Destination constr_from_ptr(long ptr) {
23                 bindings.LDKDestination raw_val = bindings.LDKDestination_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKDestination.Node.class) {
25                         return new Node(ptr, (bindings.LDKDestination.Node)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKDestination.BlindedPath.class) {
28                         return new BlindedPath(ptr, (bindings.LDKDestination.BlindedPath)raw_val);
29                 }
30                 assert false; return null; // Unreachable without extending the (internal) bindings interface
31         }
32
33         /**
34          * We're sending this onion message to a node.
35          */
36         public final static class Node extends Destination {
37                 public final byte[] node;
38                 private Node(long ptr, bindings.LDKDestination.Node obj) {
39                         super(null, ptr);
40                         this.node = obj.node;
41                 }
42         }
43         /**
44          * We're sending this onion message to a blinded path.
45          */
46         public final static class BlindedPath extends Destination {
47                 public final org.ldk.structs.BlindedPath blinded_path;
48                 private BlindedPath(long ptr, bindings.LDKDestination.BlindedPath obj) {
49                         super(null, ptr);
50                         long blinded_path = obj.blinded_path;
51                         org.ldk.structs.BlindedPath blinded_path_hu_conv = null; if (blinded_path < 0 || blinded_path > 4096) { blinded_path_hu_conv = new org.ldk.structs.BlindedPath(null, blinded_path); }
52                         if (blinded_path_hu_conv != null) { blinded_path_hu_conv.ptrs_to.add(this); };
53                         this.blinded_path = blinded_path_hu_conv;
54                 }
55         }
56         long clone_ptr() {
57                 long ret = bindings.Destination_clone_ptr(this.ptr);
58                 Reference.reachabilityFence(this);
59                 return ret;
60         }
61
62         /**
63          * Creates a copy of the Destination
64          */
65         public Destination clone() {
66                 long ret = bindings.Destination_clone(this.ptr);
67                 Reference.reachabilityFence(this);
68                 if (ret >= 0 && ret <= 4096) { return null; }
69                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
70                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
71                 return ret_hu_conv;
72         }
73
74         /**
75          * Utility method to constructs a new Node-variant Destination
76          */
77         public static Destination node(byte[] a) {
78                 long ret = bindings.Destination_node(InternalUtils.check_arr_len(a, 33));
79                 Reference.reachabilityFence(a);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * Utility method to constructs a new BlindedPath-variant Destination
88          */
89         public static Destination blinded_path(org.ldk.structs.BlindedPath a) {
90                 long ret = bindings.Destination_blinded_path(a == null ? 0 : a.ptr);
91                 Reference.reachabilityFence(a);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
96                 return ret_hu_conv;
97         }
98
99 }