[Java] Properly convert strings to/from Modified UTF-8
[ldk-java] / src / main / java / org / ldk / structs / Result_NoneErrorZ.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_NoneErrorZ extends CommonBase {
11         private Result_NoneErrorZ(Object _dummy, long ptr) { super(ptr); }
12         protected void finalize() throws Throwable {
13                 if (ptr != 0) { bindings.CResult_NoneErrorZ_free(ptr); } super.finalize();
14         }
15
16         static Result_NoneErrorZ constr_from_ptr(long ptr) {
17                 if (bindings.CResult_NoneErrorZ_is_ok(ptr)) {
18                         return new Result_NoneErrorZ_OK(null, ptr);
19                 } else {
20                         return new Result_NoneErrorZ_Err(null, ptr);
21                 }
22         }
23         public static final class Result_NoneErrorZ_OK extends Result_NoneErrorZ {
24                 private Result_NoneErrorZ_OK(Object _dummy, long ptr) {
25                         super(_dummy, ptr);
26                 }
27         }
28
29         public static final class Result_NoneErrorZ_Err extends Result_NoneErrorZ {
30                 public final IOError err;
31                 private Result_NoneErrorZ_Err(Object _dummy, long ptr) {
32                         super(_dummy, ptr);
33                         this.err = bindings.CResult_NoneErrorZ_get_err(ptr);
34                 }
35         }
36
37         /**
38          * Creates a new CResult_NoneErrorZ in the success state.
39          */
40         public static Result_NoneErrorZ ok() {
41                 long ret = bindings.CResult_NoneErrorZ_ok();
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
44                 return ret_hu_conv;
45         }
46
47         /**
48          * Creates a new CResult_NoneErrorZ in the error state.
49          */
50         public static Result_NoneErrorZ err(org.ldk.enums.IOError e) {
51                 long ret = bindings.CResult_NoneErrorZ_err(e);
52                 Reference.reachabilityFence(e);
53                 if (ret >= 0 && ret <= 4096) { return null; }
54                 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Checks if the given object is currently in the success state
60          */
61         public boolean is_ok() {
62                 boolean ret = bindings.CResult_NoneErrorZ_is_ok(this.ptr);
63                 Reference.reachabilityFence(this);
64                 return ret;
65         }
66
67         long clone_ptr() {
68                 long ret = bindings.CResult_NoneErrorZ_clone_ptr(this.ptr);
69                 Reference.reachabilityFence(this);
70                 return ret;
71         }
72
73         /**
74          * Creates a new CResult_NoneErrorZ which has the same data as `orig`
75          * but with all dynamically-allocated buffers duplicated in new buffers.
76          */
77         public Result_NoneErrorZ clone() {
78                 long ret = bindings.CResult_NoneErrorZ_clone(this.ptr);
79                 Reference.reachabilityFence(this);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
82                 return ret_hu_conv;
83         }
84
85 }