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 * [`Score`] 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 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);
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 FixedPenaltyScorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FixedPenaltyScorer(null, ret); }
49 ret_hu_conv.ptrs_to.add(ret_hu_conv);
54 * Constructs a new Score which calls the relevant methods on this_arg.
55 * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
57 public Score as_Score() {
58 long ret = bindings.FixedPenaltyScorer_as_Score(this.ptr);
59 Reference.reachabilityFence(this);
60 if (ret >= 0 && ret <= 4096) { return null; }
61 Score ret_hu_conv = new Score(null, ret);
62 ret_hu_conv.ptrs_to.add(this);
67 * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read
69 public byte[] write() {
70 byte[] ret = bindings.FixedPenaltyScorer_write(this.ptr);
71 Reference.reachabilityFence(this);
76 * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write
78 public static Result_FixedPenaltyScorerDecodeErrorZ read(byte[] ser, long arg) {
79 long ret = bindings.FixedPenaltyScorer_read(ser, arg);
80 Reference.reachabilityFence(ser);
81 Reference.reachabilityFence(arg);
82 if (ret >= 0 && ret <= 4096) { return null; }
83 Result_FixedPenaltyScorerDecodeErrorZ ret_hu_conv = Result_FixedPenaltyScorerDecodeErrorZ.constr_from_ptr(ret);