[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / SendSuccess.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  * Result of successfully [sending an onion message].
13  * 
14  * [sending an onion message]: OnionMessenger::send_onion_message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class SendSuccess extends CommonBase {
18         private SendSuccess(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.SendSuccess_free(ptr); }
23         }
24         static SendSuccess constr_from_ptr(long ptr) {
25                 bindings.LDKSendSuccess raw_val = bindings.LDKSendSuccess_ref_from_ptr(ptr);
26                 if (raw_val.getClass() == bindings.LDKSendSuccess.Buffered.class) {
27                         return new Buffered(ptr, (bindings.LDKSendSuccess.Buffered)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKSendSuccess.BufferedAwaitingConnection.class) {
30                         return new BufferedAwaitingConnection(ptr, (bindings.LDKSendSuccess.BufferedAwaitingConnection)raw_val);
31                 }
32                 assert false; return null; // Unreachable without extending the (internal) bindings interface
33         }
34
35         /**
36          * The message was buffered and will be sent once it is processed by
37          * [`OnionMessageHandler::next_onion_message_for_peer`].
38          */
39         public final static class Buffered extends SendSuccess {
40                 private Buffered(long ptr, bindings.LDKSendSuccess.Buffered obj) {
41                         super(null, ptr);
42                 }
43         }
44         /**
45          * The message was buffered and will be sent once the node is connected as a peer and it is
46          * processed by [`OnionMessageHandler::next_onion_message_for_peer`].
47          */
48         public final static class BufferedAwaitingConnection extends SendSuccess {
49                 public final byte[] buffered_awaiting_connection;
50                 private BufferedAwaitingConnection(long ptr, bindings.LDKSendSuccess.BufferedAwaitingConnection obj) {
51                         super(null, ptr);
52                         this.buffered_awaiting_connection = obj.buffered_awaiting_connection;
53                 }
54         }
55         long clone_ptr() {
56                 long ret = bindings.SendSuccess_clone_ptr(this.ptr);
57                 Reference.reachabilityFence(this);
58                 return ret;
59         }
60
61         /**
62          * Creates a copy of the SendSuccess
63          */
64         public SendSuccess clone() {
65                 long ret = bindings.SendSuccess_clone(this.ptr);
66                 Reference.reachabilityFence(this);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.SendSuccess ret_hu_conv = org.ldk.structs.SendSuccess.constr_from_ptr(ret);
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Utility method to constructs a new Buffered-variant SendSuccess
75          */
76         public static SendSuccess buffered() {
77                 long ret = bindings.SendSuccess_buffered();
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.SendSuccess ret_hu_conv = org.ldk.structs.SendSuccess.constr_from_ptr(ret);
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess
86          */
87         public static SendSuccess buffered_awaiting_connection(byte[] a) {
88                 long ret = bindings.SendSuccess_buffered_awaiting_connection(InternalUtils.check_arr_len(a, 33));
89                 Reference.reachabilityFence(a);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.SendSuccess ret_hu_conv = org.ldk.structs.SendSuccess.constr_from_ptr(ret);
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Checks if two SendSuccesss contain equal inner contents.
98          * This ignores pointers and is_owned flags and looks at the values in fields.
99          */
100         public boolean eq(org.ldk.structs.SendSuccess b) {
101                 boolean ret = bindings.SendSuccess_eq(this.ptr, b == null ? 0 : b.ptr);
102                 Reference.reachabilityFence(this);
103                 Reference.reachabilityFence(b);
104                 return ret;
105         }
106
107         @Override public boolean equals(Object o) {
108                 if (!(o instanceof SendSuccess)) return false;
109                 return this.eq((SendSuccess)o);
110         }
111 }