package mp.code; import mp.code.data.Cursor; import mp.code.exceptions.ControllerException; import java.util.Optional; public class CursorController { private final long ptr; CursorController(long ptr) { this.ptr = ptr; } private static native Cursor try_recv(long self) throws ControllerException; public Optional tryRecv() throws ControllerException { return Optional.ofNullable(try_recv(this.ptr)); } private static native Cursor recv(long self) throws ControllerException; public Cursor recv() throws ControllerException { return recv(this.ptr); } private static native void send(long self, Cursor cursor) throws ControllerException; public void send(Cursor cursor) throws ControllerException { send(this.ptr, cursor); } private static native void free(long self); @Override protected void finalize() { free(this.ptr); } }