3e318d81dc977465edb50381d7504b87dea24a3c
[ldk-java] / src / main / java / org / ldk / structs / Persist.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
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class Persist extends CommonBase {
10         final bindings.LDKPersist bindings_instance;
11         Persist(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12         private Persist(bindings.LDKPersist arg) {
13                 super(bindings.LDKPersist_new(arg));
14                 this.ptrs_to.add(arg);
15                 this.bindings_instance = arg;
16         }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 if (ptr != 0) { bindings.Persist_free(ptr); } super.finalize();
20         }
21
22         public static interface PersistInterface {
23                 Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data);
24                 Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data);
25         }
26         private static class LDKPersistHolder { Persist held; }
27         public static Persist new_impl(PersistInterface arg) {
28                 final LDKPersistHolder impl_holder = new LDKPersistHolder();
29                 impl_holder.held = new Persist(new bindings.LDKPersist() {
30                         @Override public long persist_new_channel(long id, long data) {
31                                 OutPoint id_hu_conv = new OutPoint(null, id);
32                                 id_hu_conv.ptrs_to.add(this);
33                                 ChannelMonitor data_hu_conv = new ChannelMonitor(null, data);
34                                 Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(id_hu_conv, data_hu_conv);
35                                 long result = ret != null ? ret.ptr : 0;
36                                 return result;
37                         }
38                         @Override public long update_persisted_channel(long id, long update, long data) {
39                                 OutPoint id_hu_conv = new OutPoint(null, id);
40                                 id_hu_conv.ptrs_to.add(this);
41                                 ChannelMonitorUpdate update_hu_conv = new ChannelMonitorUpdate(null, update);
42                                 ChannelMonitor data_hu_conv = new ChannelMonitor(null, data);
43                                 Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(id_hu_conv, update_hu_conv, data_hu_conv);
44                                 long result = ret != null ? ret.ptr : 0;
45                                 return result;
46                         }
47                 });
48                 return impl_holder.held;
49         }
50         public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data) {
51                 long ret = bindings.Persist_persist_new_channel(this.ptr, id == null ? 0 : id.ptr & ~1, data == null ? 0 : data.ptr & ~1);
52                 Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
53                 this.ptrs_to.add(id);
54                 this.ptrs_to.add(data);
55                 return ret_hu_conv;
56         }
57
58         public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data) {
59                 long ret = bindings.Persist_update_persisted_channel(this.ptr, id == null ? 0 : id.ptr & ~1, update == null ? 0 : update.ptr & ~1, data == null ? 0 : data.ptr & ~1);
60                 Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
61                 this.ptrs_to.add(id);
62                 this.ptrs_to.add(update);
63                 this.ptrs_to.add(data);
64                 return ret_hu_conv;
65         }
66
67 }