Class DefaultClassInstantiator

  • All Implemented Interfaces:
    IClassInstantiator

    public class DefaultClassInstantiator
    extends Object
    implements IClassInstantiator
    Default class instantiator that is pretty limited. It just hope that the mocked class has a public empty constructor.
    Author:
    Henri Tremblay
    • Constructor Detail

      • DefaultClassInstantiator

        public DefaultClassInstantiator()
    • Method Detail

      • getConstructorToUse

        public Constructor<?> getConstructorToUse​(Class<?> clazz)
        Return the constructor considered the best to use with this class. Algorithm is: No args constructor and then first constructor defined in the class
        Parameters:
        clazz - Class in which constructor is searched
        Returns:
        Constructor to use
      • getArgsForTypes

        public Object[] getArgsForTypes​(Class<?>[] methodTypes)
                                 throws InstantiationException
        Get some default instances of provided classes
        Parameters:
        methodTypes - Classes to instantiate
        Returns:
        Instances of methodTypes in order
        Throws:
        InstantiationException - Thrown if the class instantiation fails