]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/MessageHandler.java
[Java] Update auto-generated Java structs
[ldk-java] / src / main / java / org / ldk / structs / MessageHandler.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  * Provides references to trait impls which handle different types of messages.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class MessageHandler extends CommonBase {
16         MessageHandler(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.MessageHandler_free(ptr); }
21         }
22
23         /**
24          * A message handler which handles messages specific to channels. Usually this is just a
25          * [`ChannelManager`] object or an [`ErroringMessageHandler`].
26          * 
27          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
28          */
29         public ChannelMessageHandler get_chan_handler() {
30                 long ret = bindings.MessageHandler_get_chan_handler(this.ptr);
31                 Reference.reachabilityFence(this);
32                 if (ret >= 0 && ret <= 4096) { return null; }
33                 ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
34                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
35                 return ret_hu_conv;
36         }
37
38         /**
39          * A message handler which handles messages specific to channels. Usually this is just a
40          * [`ChannelManager`] object or an [`ErroringMessageHandler`].
41          * 
42          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
43          */
44         public void set_chan_handler(ChannelMessageHandler val) {
45                 bindings.MessageHandler_set_chan_handler(this.ptr, val == null ? 0 : val.ptr);
46                 Reference.reachabilityFence(this);
47                 Reference.reachabilityFence(val);
48                 if (this != null) { this.ptrs_to.add(val); };
49         }
50
51         /**
52          * A message handler which handles messages updating our knowledge of the network channel
53          * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`].
54          * 
55          * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync
56          */
57         public RoutingMessageHandler get_route_handler() {
58                 long ret = bindings.MessageHandler_get_route_handler(this.ptr);
59                 Reference.reachabilityFence(this);
60                 if (ret >= 0 && ret <= 4096) { return null; }
61                 RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
62                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
63                 return ret_hu_conv;
64         }
65
66         /**
67          * A message handler which handles messages updating our knowledge of the network channel
68          * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`].
69          * 
70          * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync
71          */
72         public void set_route_handler(RoutingMessageHandler val) {
73                 bindings.MessageHandler_set_route_handler(this.ptr, val == null ? 0 : val.ptr);
74                 Reference.reachabilityFence(this);
75                 Reference.reachabilityFence(val);
76                 if (this != null) { this.ptrs_to.add(val); };
77         }
78
79         /**
80          * Constructs a new MessageHandler given each field
81          */
82         public static MessageHandler of(ChannelMessageHandler chan_handler_arg, RoutingMessageHandler route_handler_arg) {
83                 long ret = bindings.MessageHandler_new(chan_handler_arg == null ? 0 : chan_handler_arg.ptr, route_handler_arg == null ? 0 : route_handler_arg.ptr);
84                 Reference.reachabilityFence(chan_handler_arg);
85                 Reference.reachabilityFence(route_handler_arg);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.MessageHandler ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.MessageHandler(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(chan_handler_arg); };
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(route_handler_arg); };
91                 return ret_hu_conv;
92         }
93
94 }