1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * [`ScoreLookUp`] implementation that uses a fixed penalty.
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 {
20 if (ptr != 0) { bindings.FixedPenaltyScorer_free(ptr); }
24 long ret = bindings.FixedPenaltyScorer_clone_ptr(this.ptr);
25 Reference.reachabilityFence(this);
30 * Creates a copy of the FixedPenaltyScorer
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 org.ldk.structs.FixedPenaltyScorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FixedPenaltyScorer(null, ret); }
37 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
42 * Creates a new scorer using `penalty_msat`.
44 public static FixedPenaltyScorer with_penalty(long penalty_msat) {
45 long ret = bindings.FixedPenaltyScorer_with_penalty(penalty_msat);
46 Reference.reachabilityFence(penalty_msat);
47 if (ret >= 0 && ret <= 4096) { return null; }
48 org.ldk.structs.FixedPenaltyScorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FixedPenaltyScorer(null, ret); }
49 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
54 * Constructs a new ScoreLookUp which calls the relevant methods on this_arg.
55 * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is
57 public ScoreLookUp as_ScoreLookUp() {
58 long ret = bindings.FixedPenaltyScorer_as_ScoreLookUp(this.ptr);
59 Reference.reachabilityFence(this);
60 if (ret >= 0 && ret <= 4096) { return null; }
61 ScoreLookUp ret_hu_conv = new ScoreLookUp(null, ret);
62 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
67 * Constructs a new ScoreUpdate which calls the relevant methods on this_arg.
68 * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is
70 public ScoreUpdate as_ScoreUpdate() {
71 long ret = bindings.FixedPenaltyScorer_as_ScoreUpdate(this.ptr);
72 Reference.reachabilityFence(this);
73 if (ret >= 0 && ret <= 4096) { return null; }
74 ScoreUpdate ret_hu_conv = new ScoreUpdate(null, ret);
75 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
80 * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read
82 public byte[] write() {
83 byte[] ret = bindings.FixedPenaltyScorer_write(this.ptr);
84 Reference.reachabilityFence(this);
89 * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write
91 public static Result_FixedPenaltyScorerDecodeErrorZ read(byte[] ser, long arg) {
92 long ret = bindings.FixedPenaltyScorer_read(ser, arg);
93 Reference.reachabilityFence(ser);
94 Reference.reachabilityFence(arg);
95 if (ret >= 0 && ret <= 4096) { return null; }
96 Result_FixedPenaltyScorerDecodeErrorZ ret_hu_conv = Result_FixedPenaltyScorerDecodeErrorZ.constr_from_ptr(ret);