Package com.helger.base.lang.clazz
Class FactoryNewInstance<DATATYPE>
java.lang.Object
com.helger.base.lang.clazz.FactoryNewInstance<DATATYPE>
- Type Parameters:
DATATYPE- The return type of the factory
- All Implemented Interfaces:
Supplier<DATATYPE>
Implementation of
Supplier that always creates a new instance via reflection- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionFactoryNewInstance(@Nullable Class<? extends DATATYPE> aClass, boolean bCheckInstancable) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic <DATATYPE> @NonNull FactoryNewInstance<DATATYPE> Create a new factory without an instancability check.static <DATATYPE> @NonNull FactoryNewInstance<DATATYPE> Create a new factory.boolean@Nullable DATATYPEget()Create a new instance of the factory class via reflection.inthashCode()toString()
-
Constructor Details
-
FactoryNewInstance
Constructor.- Parameters:
aClass- The class to instantiate. May benull.bCheckInstancable-trueto check that the class can be instantiated,falseto skip the check.
-
-
Method Details
-
getFactoryClass
- Returns:
- The class to be instantiated. May be
null.
-
get
Create a new instance of the factory class via reflection. -
equals
-
hashCode
public int hashCode() -
toString
-
create
public static <DATATYPE> @NonNull FactoryNewInstance<DATATYPE> create(@Nullable Class<DATATYPE> aClass) Create a new factory without an instancability check.- Type Parameters:
DATATYPE- The data type to be created- Parameters:
aClass- The class to instantiate. May benull.- Returns:
- The new factory instance. Never
null.
-
create
public static <DATATYPE> @NonNull FactoryNewInstance<DATATYPE> create(@Nullable Class<DATATYPE> aClass, boolean bCheckInstancable) Create a new factory.- Type Parameters:
DATATYPE- The data type to be created- Parameters:
aClass- The class to instantiate. May benull.bCheckInstancable-trueto check that the class can be instantiated,falseto skip the check.- Returns:
- The new factory instance. Never
null.
-