From 7444c2b1f281b5b147717ba2a2ed6798c66a057b Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 27 Apr 2020 17:42:07 +0800 Subject: Resized the logo to reduce plugin size. Refactored code for a better implementation of async and blocking task. --- .../abstracts/InvokableBlockingOperation.java | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/keuin/kbackupfabric/operation/abstracts/InvokableBlockingOperation.java (limited to 'src/main/java/com/keuin/kbackupfabric/operation/abstracts/InvokableBlockingOperation.java') diff --git a/src/main/java/com/keuin/kbackupfabric/operation/abstracts/InvokableBlockingOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/abstracts/InvokableBlockingOperation.java new file mode 100644 index 0000000..b1a3748 --- /dev/null +++ b/src/main/java/com/keuin/kbackupfabric/operation/abstracts/InvokableBlockingOperation.java @@ -0,0 +1,39 @@ +package com.keuin.kbackupfabric.operation.abstracts; + +import com.keuin.kbackupfabric.operation.abstracts.i.Blocking; + +public abstract class InvokableBlockingOperation extends InvokableOperation implements Blocking { + + private final AbstractBlockingOperation operation = new AbstractBlockingOperation() { + @Override + protected boolean blockingContext() { + return InvokableBlockingOperation.this.blockingContext(); + } + }; + + @Override + protected final boolean operate() { + return operation.operate(); + } + + /** + * Implement your blocked operation here. + * + * @return stat code. + */ + protected abstract boolean blockingContext(); + + protected void block(boolean blockState) { + operation.block(blockState); + } + + protected void noUnblocking(boolean b) { + operation.noUnblocking(b); + } + + @Override + public final boolean isBlocked() { + return operation.isBlocked(); + } + +} -- cgit v1.2.3