java.lang.Object
provided.utils.loader.impl.AObjectLoader<ReturnT>
provided.utils.loader.impl.ObjectLoader<ReturnT>
- Type Parameters:
ReturnT
- The type of object to be created.
- All Implemented Interfaces:
IObjectLoader<ReturnT>
Factory that dynamically class loads and instantiates an object of type ReturnT
This is a non-recursive object loader that should be used when the fully qualified name of the desired class can be determined BEFORE the
object loader is invoked.
- Author:
- Stephen Wong
-
Field Summary
FieldsModifier and TypeFieldDescriptionLambda function to return an error object of type ReturnTFields inherited from class provided.utils.loader.impl.AObjectLoader
logger
-
Constructor Summary
ConstructorsConstructorDescriptionObjectLoader(Function<Object[],ReturnT> errorFac)
Constructor for the class. -
Method Summary
Modifier and TypeMethodDescriptionprotected ReturnT
errorHandler(Exception ex, String className, Object... args)
Prints the given Exception to stderr and then invokes the stored errorFac to generate an error object.Methods inherited from class provided.utils.loader.impl.AObjectLoader
loadInstance
-
Field Details
-
errorFac
Lambda function to return an error object of type ReturnT
-
-
Constructor Details
-
ObjectLoader
Constructor for the class. The given errorFac is used to generate instances when the loadInstance() method is otherwise unable to do so because of a processing error.- Parameters:
errorFac
- A factory method that takes the same array of input parameters that loadInstance() takes and returns an instance of ReturnT.
-
-
Method Details
-
errorHandler
Prints the given Exception to stderr and then invokes the stored errorFac to generate an error object.- Specified by:
errorHandler
in classAObjectLoader<ReturnT>
- Parameters:
ex
- The Exception that was generatedclassName
- The fully qualified name of the class that was attempted to be loadedargs
- The constructor parameters for the given class name.- Returns:
- An "error" object
-