Project cleanup pre merge.

This commit is contained in:
2023-07-15 09:23:48 -04:00
parent 134b651df8
commit 9bbdef224d
747 changed files with 99704 additions and 101200 deletions
+77 -89
View File
@@ -22,105 +22,93 @@ import java.lang.reflect.Method;
* <p>
* Intended to be used with the {@link JobScheduler}, a BasicScheduledJob will
* hold a reference to an execution method.
*
*
* @author Burfo
**/
public class BasicScheduledJob extends AbstractJob {
private Method execution;
private Object referenceObject;
private Method execution;
private Object referenceObject;
/**
* Generates a new BasicScheduledJob that executes a static method that has
* no parameters.
*
* @param methodName
* Name of the static method to execute, such as "myMethod"
*
* @param methodClass
* The class in which {@code methodName} exists
*/
public BasicScheduledJob(String methodName, Class methodClass) {
this(methodName, methodClass, null);
}
/**
* Generates a new BasicScheduledJob that executes a static method that has
* no parameters.
*
* @param methodName Name of the static method to execute, such as "myMethod"
* @param methodClass The class in which {@code methodName} exists
*/
public BasicScheduledJob(String methodName, Class methodClass) {
this(methodName, methodClass, null);
}
/**
* Generates a new BasicScheduledJob that executes an instance method that
* has no parameters.
*
* @param methodName
* Name of the instance method to execute, such as "myMethod"
*
* @param methodClass
* The class in which {@code methodName} exists
*
* @param referenceObject
* Instance of {@code methodClass} against which {@code
* methodName} should be executed
*/
@SuppressWarnings("unchecked")
public BasicScheduledJob(String methodName, Class methodClass, Object referenceObject) {
super();
Method method = null;
try {
method = methodClass.getMethod(methodName);
} catch (SecurityException e) {
Logger.error( e);
} catch (NoSuchMethodException e) {
Logger.error( e);
}
setData(method, null);
}
/**
* Generates a new BasicScheduledJob that executes an instance method that
* has no parameters.
*
* @param methodName Name of the instance method to execute, such as "myMethod"
* @param methodClass The class in which {@code methodName} exists
* @param referenceObject Instance of {@code methodClass} against which {@code
* methodName} should be executed
*/
@SuppressWarnings("unchecked")
public BasicScheduledJob(String methodName, Class methodClass, Object referenceObject) {
super();
Method method = null;
try {
method = methodClass.getMethod(methodName);
} catch (SecurityException e) {
Logger.error(e);
} catch (NoSuchMethodException e) {
Logger.error(e);
}
setData(method, null);
}
/**
* Generates a new BasicScheduledJob that executes a static method that has
* no parameters.
*
* @param executionMethod
* Reference to the static method to execute
*/
public BasicScheduledJob(Method executionMethod) {
this(executionMethod, null);
}
/**
* Generates a new BasicScheduledJob that executes a static method that has
* no parameters.
*
* @param executionMethod Reference to the static method to execute
*/
public BasicScheduledJob(Method executionMethod) {
this(executionMethod, null);
}
/**
* Generates a new BasicScheduledJob that executes an instance method that
* has no parameters.
*
* @param executionMethod
* Reference to the static method to execute
*
* @param referenceObject
* Instanciated object against which {@code executionMethod}
* should be executed
*/
public BasicScheduledJob(Method executionMethod, Object referenceObject) {
super();
setData(executionMethod, referenceObject);
}
/**
* Generates a new BasicScheduledJob that executes an instance method that
* has no parameters.
*
* @param executionMethod Reference to the static method to execute
* @param referenceObject Instanciated object against which {@code executionMethod}
* should be executed
*/
public BasicScheduledJob(Method executionMethod, Object referenceObject) {
super();
setData(executionMethod, referenceObject);
}
private void setData(Method executionMethod, Object referenceObject) {
this.execution = executionMethod;
this.referenceObject = referenceObject;
if (execution == null) {
Logger.error("BasicScheduledJob instanciated with no execution method.");
}
}
private void setData(Method executionMethod, Object referenceObject) {
this.execution = executionMethod;
this.referenceObject = referenceObject;
if (execution == null) {
Logger.error("BasicScheduledJob instanciated with no execution method.");
}
}
@Override
protected void doJob() {
if (execution == null) {
Logger.error( "BasicScheduledJob executed with nothing to execute.");
return;
}
@Override
protected void doJob() {
if (execution == null) {
Logger.error("BasicScheduledJob executed with nothing to execute.");
return;
}
try {
execution.invoke(referenceObject);
} catch (IllegalArgumentException | IllegalAccessException e) {
Logger.error( "BasicScheduledJob execution failed. Method: " + execution.toString(), e);
} catch (InvocationTargetException e) {
Logger.error( "BasicScheduledJob execution failed. " + "Method: " + execution.toString(), e);
}
}
try {
execution.invoke(referenceObject);
} catch (IllegalArgumentException | IllegalAccessException e) {
Logger.error("BasicScheduledJob execution failed. Method: " + execution.toString(), e);
} catch (InvocationTargetException e) {
Logger.error("BasicScheduledJob execution failed. " + "Method: " + execution.toString(), e);
}
}
}