- add prototype Interactioncheck impementation.
- refactor dependency injection to have all widely used dependencies in the Marinara class.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package net.tomatentum.marinara.checks;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public record AppliedCheck(InteractionCheck<?> check, Annotation annotation) {
|
||||
|
||||
public boolean pre() {
|
||||
try {
|
||||
return (boolean) check.getClass().getMethod("preExec", annotation.getClass()).invoke(check, annotation);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean post() {
|
||||
try {
|
||||
return (boolean) check.getClass().getMethod("postExec", annotation.getClass()).invoke(check, annotation);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package net.tomatentum.marinara.checks;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public interface InteractionCheck<A extends Annotation> {
|
||||
|
||||
public boolean preExec(A annotation);
|
||||
public boolean postExec(A annotation);
|
||||
|
||||
}
|
Reference in New Issue
Block a user