ca8b6acb6a05ca45433aa88248228256ff3786da
[ldk-java] / src / main / java / org / ldk / structs / FixedPenaltyScorer.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  * [`Score`] implementation that uses a fixed penalty.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class FixedPenaltyScorer extends CommonBase {
16         FixedPenaltyScorer(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.FixedPenaltyScorer_free(ptr); }
21         }
22
23         long clone_ptr() {
24                 long ret = bindings.FixedPenaltyScorer_clone_ptr(this.ptr);
25                 Reference.reachabilityFence(this);
26                 return ret;
27         }
28
29         /**
30          * Creates a copy of the FixedPenaltyScorer
31          */
32         public FixedPenaltyScorer clone() {
33                 long ret = bindings.FixedPenaltyScorer_clone(this.ptr);
34                 Reference.reachabilityFence(this);
35                 if (ret >= 0 && ret <= 4096) { return null; }
36                 FixedPenaltyScorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FixedPenaltyScorer(null, ret); }
37                 ret_hu_conv.ptrs_to.add(this);
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read
43          */
44         public byte[] write() {
45                 byte[] ret = bindings.FixedPenaltyScorer_write(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write
52          */
53         public static Result_FixedPenaltyScorerDecodeErrorZ read(byte[] ser) {
54                 long ret = bindings.FixedPenaltyScorer_read(ser);
55                 Reference.reachabilityFence(ser);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 Result_FixedPenaltyScorerDecodeErrorZ ret_hu_conv = Result_FixedPenaltyScorerDecodeErrorZ.constr_from_ptr(ret);
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Creates a new scorer using `penalty_msat`.
63          */
64         public static FixedPenaltyScorer with_penalty(long penalty_msat) {
65                 long ret = bindings.FixedPenaltyScorer_with_penalty(penalty_msat);
66                 Reference.reachabilityFence(penalty_msat);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 FixedPenaltyScorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FixedPenaltyScorer(null, ret); }
69                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Constructs a new Score which calls the relevant methods on this_arg.
75          * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
76          */
77         public Score as_Score() {
78                 long ret = bindings.FixedPenaltyScorer_as_Score(this.ptr);
79                 Reference.reachabilityFence(this);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 Score ret_hu_conv = new Score(null, ret);
82                 ret_hu_conv.ptrs_to.add(this);
83                 return ret_hu_conv;
84         }
85
86 }