6b99a12d09694a127192c1394192f688dd85d7f3
[ldk-java] / src / main / java / org / ldk / structs / Result_ScoringParametersDecodeErrorZ.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 public class Result_ScoringParametersDecodeErrorZ extends CommonBase {
11         private Result_ScoringParametersDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
12         protected void finalize() throws Throwable {
13                 if (ptr != 0) { bindings.CResult_ScoringParametersDecodeErrorZ_free(ptr); } super.finalize();
14         }
15
16         static Result_ScoringParametersDecodeErrorZ constr_from_ptr(long ptr) {
17                 if (bindings.CResult_ScoringParametersDecodeErrorZ_is_ok(ptr)) {
18                         return new Result_ScoringParametersDecodeErrorZ_OK(null, ptr);
19                 } else {
20                         return new Result_ScoringParametersDecodeErrorZ_Err(null, ptr);
21                 }
22         }
23         public static final class Result_ScoringParametersDecodeErrorZ_OK extends Result_ScoringParametersDecodeErrorZ {
24                 public final ScoringParameters res;
25                 private Result_ScoringParametersDecodeErrorZ_OK(Object _dummy, long ptr) {
26                         super(_dummy, ptr);
27                         long res = bindings.CResult_ScoringParametersDecodeErrorZ_get_ok(ptr);
28                         ScoringParameters res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ScoringParameters(null, res); }
29                         res_hu_conv.ptrs_to.add(this);
30                         this.res = res_hu_conv;
31                 }
32         }
33
34         public static final class Result_ScoringParametersDecodeErrorZ_Err extends Result_ScoringParametersDecodeErrorZ {
35                 public final DecodeError err;
36                 private Result_ScoringParametersDecodeErrorZ_Err(Object _dummy, long ptr) {
37                         super(_dummy, ptr);
38                         long err = bindings.CResult_ScoringParametersDecodeErrorZ_get_err(ptr);
39                         DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
40                         err_hu_conv.ptrs_to.add(this);
41                         this.err = err_hu_conv;
42                 }
43         }
44
45         /**
46          * Creates a new CResult_ScoringParametersDecodeErrorZ in the success state.
47          */
48         public static Result_ScoringParametersDecodeErrorZ ok(long o_base_penalty_msat_arg, long o_failure_penalty_msat_arg, short o_overuse_penalty_start_1024th_arg, long o_overuse_penalty_msat_per_1024th_arg, long o_failure_penalty_half_life_arg) {
49                 long ret = bindings.CResult_ScoringParametersDecodeErrorZ_ok(bindings.ScoringParameters_new(o_base_penalty_msat_arg, o_failure_penalty_msat_arg, o_overuse_penalty_start_1024th_arg, o_overuse_penalty_msat_per_1024th_arg, o_failure_penalty_half_life_arg));
50                 Reference.reachabilityFence(o_base_penalty_msat_arg);
51                 Reference.reachabilityFence(o_failure_penalty_msat_arg);
52                 Reference.reachabilityFence(o_overuse_penalty_start_1024th_arg);
53                 Reference.reachabilityFence(o_overuse_penalty_msat_per_1024th_arg);
54                 Reference.reachabilityFence(o_failure_penalty_half_life_arg);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 Result_ScoringParametersDecodeErrorZ ret_hu_conv = Result_ScoringParametersDecodeErrorZ.constr_from_ptr(ret);
57                 return ret_hu_conv;
58         }
59
60         /**
61          * Creates a new CResult_ScoringParametersDecodeErrorZ in the error state.
62          */
63         public static Result_ScoringParametersDecodeErrorZ err(DecodeError e) {
64                 long ret = bindings.CResult_ScoringParametersDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
65                 Reference.reachabilityFence(e);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 Result_ScoringParametersDecodeErrorZ ret_hu_conv = Result_ScoringParametersDecodeErrorZ.constr_from_ptr(ret);
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Checks if the given object is currently in the success state
73          */
74         public boolean is_ok() {
75                 boolean ret = bindings.CResult_ScoringParametersDecodeErrorZ_is_ok(this.ptr);
76                 Reference.reachabilityFence(this);
77                 return ret;
78         }
79
80 }