538a84417cdaac0b2d0dd1c3b080846da6535fcf
[ldk-java] / c_sharp / src / org / ldk / structs / PrivateRoute.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Private routing information
11  * 
12  * # Invariants
13  * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
14  */
15 public class PrivateRoute : CommonBase {
16         internal PrivateRoute(object _dummy, long ptr) : base(ptr) { }
17         ~PrivateRoute() {
18                 if (ptr != 0) { bindings.PrivateRoute_free(ptr); }
19         }
20
21         internal long clone_ptr() {
22                 long ret = bindings.PrivateRoute_clone_ptr(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * Creates a copy of the PrivateRoute
29          */
30         public PrivateRoute clone() {
31                 long ret = bindings.PrivateRoute_clone(this.ptr);
32                 GC.KeepAlive(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 org.ldk.structs.PrivateRoute ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrivateRoute(null, ret); }
35                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
36                 return ret_hu_conv;
37         }
38
39         /**
40          * Checks if two PrivateRoutes contain equal inner contents.
41          */
42         public long hash() {
43                 long ret = bindings.PrivateRoute_hash(this.ptr);
44                 GC.KeepAlive(this);
45                 return ret;
46         }
47
48         public override int GetHashCode() {
49                 return (int)this.hash();
50         }
51         /**
52          * Checks if two PrivateRoutes contain equal inner contents.
53          * This ignores pointers and is_owned flags and looks at the values in fields.
54          * Two objects with NULL inner values will be considered "equal" here.
55          */
56         public bool eq(org.ldk.structs.PrivateRoute b) {
57                 bool ret = bindings.PrivateRoute_eq(this.ptr, b == null ? 0 : b.ptr);
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(b);
60                 if (this != null) { this.ptrs_to.AddLast(b); };
61                 return ret;
62         }
63
64         public override bool Equals(object o) {
65                 if (!(o is PrivateRoute)) return false;
66                 return this.eq((PrivateRoute)o);
67         }
68         /**
69          * Creates a new (partial) route from a list of hops
70          */
71         public static Result_PrivateRouteCreationErrorZ of(org.ldk.structs.RouteHint hops) {
72                 long ret = bindings.PrivateRoute_new(hops == null ? 0 : hops.ptr);
73                 GC.KeepAlive(hops);
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 Result_PrivateRouteCreationErrorZ ret_hu_conv = Result_PrivateRouteCreationErrorZ.constr_from_ptr(ret);
76                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(hops); };
77                 return ret_hu_conv;
78         }
79
80         /**
81          * Returns the underlying list of hops
82          */
83         public RouteHint into_inner() {
84                 long ret = bindings.PrivateRoute_into_inner(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RouteHint(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
89                 if (this != null) { this.ptrs_to.AddLast(this); };
90                 return ret_hu_conv;
91         }
92
93 }
94 } } }