[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / Score.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  * A trait which can both lookup and update routing channel penalty scores.
12  * 
13  * This is used in places where both bounds are required and implemented for all types which
14  * implement [`ScoreLookUp`] and [`ScoreUpdate`].
15  * 
16  * Bindings users may need to manually implement this for their custom scoring implementations.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class Score extends CommonBase {
20         final bindings.LDKScore bindings_instance;
21         Score(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
22         private Score(bindings.LDKScore arg, bindings.LDKScoreLookUp ScoreLookUp, bindings.LDKScoreUpdate ScoreUpdate) {
23                 super(bindings.LDKScore_new(arg, ScoreLookUp, ScoreUpdate));
24                 this.ptrs_to.add(arg);
25                 this.ptrs_to.add(ScoreLookUp);
26                 this.ptrs_to.add(ScoreUpdate);
27                 this.bindings_instance = arg;
28         }
29         @Override @SuppressWarnings("deprecation")
30         protected void finalize() throws Throwable {
31                 if (ptr != 0) { bindings.Score_free(ptr); } super.finalize();
32         }
33         /**
34          * Destroys the object, freeing associated resources. After this call, any access
35          * to this object may result in a SEGFAULT or worse.
36          *
37          * You should generally NEVER call this method. You should let the garbage collector
38          * do this for you when it finalizes objects. However, it may be useful for types
39          * which represent locks and should be closed immediately to avoid holding locks
40          * until the GC runs.
41          */
42         public void destroy() {
43                 if (ptr != 0) { bindings.Score_free(ptr); }
44                 ptr = 0;
45         }
46         public static interface ScoreInterface {
47                 /**
48                  * Serialize the object into a byte array
49                  */
50                 byte[] write();
51         }
52         private static class LDKScoreHolder { Score held; }
53         public static Score new_impl(ScoreInterface arg, ScoreLookUp.ScoreLookUpInterface ScoreLookUp_impl, ScoreUpdate.ScoreUpdateInterface ScoreUpdate_impl) {
54                 final LDKScoreHolder impl_holder = new LDKScoreHolder();
55                 impl_holder.held = new Score(new bindings.LDKScore() {
56                         @Override public byte[] write() {
57                                 byte[] ret = arg.write();
58                                 Reference.reachabilityFence(arg);
59                                 return ret;
60                         }
61                 }, ScoreLookUp.new_impl(ScoreLookUp_impl).bindings_instance, ScoreUpdate.new_impl(ScoreUpdate_impl).bindings_instance);
62                 return impl_holder.held;
63         }
64
65         /**
66          * Gets the underlying ScoreLookUp.
67          */
68         public ScoreLookUp get_score_look_up() {
69                 ScoreLookUp res = new ScoreLookUp(null, bindings.LDKScore_get_ScoreLookUp(this.ptr));
70                 res.ptrs_to.add(this);
71                 return res;
72         }
73
74
75         /**
76          * Gets the underlying ScoreUpdate.
77          */
78         public ScoreUpdate get_score_update() {
79                 ScoreUpdate res = new ScoreUpdate(null, bindings.LDKScore_get_ScoreUpdate(this.ptr));
80                 res.ptrs_to.add(this);
81                 return res;
82         }
83
84         /**
85          * Serialize the object into a byte array
86          */
87         public byte[] write() {
88                 byte[] ret = bindings.Score_write(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93 }