1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class EventsProvider extends CommonBase {
10 final bindings.LDKEventsProvider bindings_instance;
11 EventsProvider(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12 private EventsProvider(bindings.LDKEventsProvider arg) {
13 super(bindings.LDKEventsProvider_new(arg));
14 this.ptrs_to.add(arg);
15 this.bindings_instance = arg;
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.EventsProvider_free(ptr); } super.finalize();
22 public static interface EventsProviderInterface {
23 Event[] get_and_clear_pending_events();
25 private static class LDKEventsProviderHolder { EventsProvider held; }
26 public static EventsProvider new_impl(EventsProviderInterface arg) {
27 final LDKEventsProviderHolder impl_holder = new LDKEventsProviderHolder();
28 impl_holder.held = new EventsProvider(new bindings.LDKEventsProvider() {
29 @Override public long[] get_and_clear_pending_events() {
30 Event[] ret = arg.get_and_clear_pending_events();
31 long[] result = Arrays.stream(ret).mapToLong(arr_conv_7 -> arr_conv_7.ptr).toArray();
36 return impl_holder.held;
38 public Event[] get_and_clear_pending_events() {
39 long[] ret = bindings.EventsProvider_get_and_clear_pending_events(this.ptr);
40 Event[] arr_conv_7_arr = new Event[ret.length];
41 for (int h = 0; h < ret.length; h++) {
42 long arr_conv_7 = ret[h];
43 Event arr_conv_7_hu_conv = Event.constr_from_ptr(arr_conv_7);
44 arr_conv_7_hu_conv.ptrs_to.add(this);
45 arr_conv_7_arr[h] = arr_conv_7_hu_conv;
47 return arr_conv_7_arr;