Class ReflectiveInstantiation

java.lang.Object
org.dbunit.annotation.runtime.ReflectiveInstantiation

public class ReflectiveInstantiation extends Object
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 Details

    • instantiate

      public static <T> T instantiate(Class<? extends T> implementationClass, String attributeDescription)
      Instantiates implementationClass via its no-arg constructor, wrapping any failure in an IllegalStateException that names attributeDescription.
      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
      Instantiates implementationClass via its no-arg constructor, for a caller that needs to report a failure in its own, more specific words rather than instantiate(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 an InvocationTargetException).