Package org.dbunit.annotation.runtime
Class ReflectiveInstantiation
java.lang.Object
org.dbunit.annotation.runtime.ReflectiveInstantiation
Reflectively instantiates, via its no-arg constructor, a class an
org.dbunit.annotation
attribute names by Class - shared by every such attribute
(DbUnitConfig.dataFileLoader(), failureHandler(), a
VerifyTableDefinitionsProvider catalog class, a DatabaseTesterFactory, and so
on) so a missing or throwing constructor is reported consistently everywhere.
Public so a binding outside org.dbunit.annotation.runtime - such as
DbUnitExtension - can reach it too.
- Since:
- 3.6.0
- Author:
- Jeff Jensen
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tinstantiate(Class<? extends T> implementationClass, String attributeDescription) InstantiatesimplementationClassvia its no-arg constructor, wrapping any failure in anIllegalStateExceptionthat namesattributeDescription.static <T> TnewInstance(Class<? extends T> implementationClass) InstantiatesimplementationClassvia its no-arg constructor, for a caller that needs to report a failure in its own, more specific words rather thaninstantiate(java.lang.Class<? extends T>, java.lang.String)'s generic message.
-
Method Details
-
instantiate
public static <T> T instantiate(Class<? extends T> implementationClass, String attributeDescription) InstantiatesimplementationClassvia its no-arg constructor, wrapping any failure in anIllegalStateExceptionthat namesattributeDescription.- Parameters:
implementationClass- The class to instantiate.attributeDescription- The annotation attribute that named this class, used only for the exception message.- Returns:
- The new instance.
- Throws:
IllegalStateException- If the no-arg constructor is missing, inaccessible, or itself throws.
-
newInstance
public static <T> T newInstance(Class<? extends T> implementationClass) throws ReflectiveOperationException InstantiatesimplementationClassvia its no-arg constructor, for a caller that needs to report a failure in its own, more specific words rather thaninstantiate(java.lang.Class<? extends T>, java.lang.String)'s generic message.- Parameters:
implementationClass- The class to instantiate.- Returns:
- The new instance.
- Throws:
ReflectiveOperationException- If the no-arg constructor is missing, inaccessible, or itself throws (as anInvocationTargetException).
-