[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / ReadOnlyNetworkGraph.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  * A read-only view of [`NetworkGraph`].
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ReadOnlyNetworkGraph extends CommonBase implements AutoCloseable {
16         ReadOnlyNetworkGraph(Object _dummy, long ptr) { super(ptr); }
17         @Override public void close() {
18                 if (ptr != 0) { bindings.ReadOnlyNetworkGraph_free(ptr); }
19         }
20
21         /**
22          * Returns information on a channel with the given id.
23          * 
24          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
25          */
26         @Nullable
27         public ChannelInfo channel(long short_channel_id) {
28                 long ret = bindings.ReadOnlyNetworkGraph_channel(this.ptr, short_channel_id);
29                 Reference.reachabilityFence(this);
30                 Reference.reachabilityFence(short_channel_id);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Returns the list of channels in the graph
39          */
40         public long[] list_channels() {
41                 long[] ret = bindings.ReadOnlyNetworkGraph_list_channels(this.ptr);
42                 Reference.reachabilityFence(this);
43                 return ret;
44         }
45
46         /**
47          * Returns information on a node with the given id.
48          * 
49          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
50          */
51         @Nullable
52         public NodeInfo node(org.ldk.structs.NodeId node_id) {
53                 long ret = bindings.ReadOnlyNetworkGraph_node(this.ptr, node_id == null ? 0 : node_id.ptr);
54                 Reference.reachabilityFence(this);
55                 Reference.reachabilityFence(node_id);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 org.ldk.structs.NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeInfo(null, ret); }
58                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
59                 if (this != null) { this.ptrs_to.add(node_id); };
60                 return ret_hu_conv;
61         }
62
63         /**
64          * Returns the list of nodes in the graph
65          */
66         public NodeId[] list_nodes() {
67                 long[] ret = bindings.ReadOnlyNetworkGraph_list_nodes(this.ptr);
68                 Reference.reachabilityFence(this);
69                 int ret_conv_8_len = ret.length;
70                 NodeId[] ret_conv_8_arr = new NodeId[ret_conv_8_len];
71                 for (int i = 0; i < ret_conv_8_len; i++) {
72                         long ret_conv_8 = ret[i];
73                         org.ldk.structs.NodeId ret_conv_8_hu_conv = null; if (ret_conv_8 < 0 || ret_conv_8 > 4096) { ret_conv_8_hu_conv = new org.ldk.structs.NodeId(null, ret_conv_8); }
74                         if (ret_conv_8_hu_conv != null) { ret_conv_8_hu_conv.ptrs_to.add(this); };
75                         ret_conv_8_arr[i] = ret_conv_8_hu_conv;
76                 }
77                 return ret_conv_8_arr;
78         }
79
80         /**
81          * Get network addresses by node id.
82          * Returns None if the requested node is completely unknown,
83          * or if node announcement for the node was never received.
84          */
85         public Option_CVec_SocketAddressZZ get_addresses(byte[] pubkey) {
86                 long ret = bindings.ReadOnlyNetworkGraph_get_addresses(this.ptr, InternalUtils.check_arr_len(pubkey, 33));
87                 Reference.reachabilityFence(this);
88                 Reference.reachabilityFence(pubkey);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.Option_CVec_SocketAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_SocketAddressZZ.constr_from_ptr(ret);
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
92                 return ret_hu_conv;
93         }
94
95 }