Class SingleInstantiatorStrategy

java.lang.Object
org.objenesis.strategy.SingleInstantiatorStrategy
All Implemented Interfaces:
InstantiatorStrategy

public class SingleInstantiatorStrategy extends Object implements InstantiatorStrategy
Strategy returning only one instantiator type. Useful if you know on which JVM Objenesis will be used and want to specify it explicitly.
  • Constructor Details

    • SingleInstantiatorStrategy

      public SingleInstantiatorStrategy(Class<T> instantiator)
      Create a strategy that will return always the same instantiator type. We assume this instantiator has one constructor taking the class to instantiate in parameter.
      Type Parameters:
      T - the type we want to instantiate
      Parameters:
      instantiator - the instantiator type
  • Method Details

    • newInstantiatorOf

      public <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type)
      Return an instantiator for the wanted type and of the one and only type of instantiator returned by this class.
      Specified by:
      newInstantiatorOf in interface InstantiatorStrategy
      Type Parameters:
      T - the type we want to instantiate
      Parameters:
      type - Class to instantiate
      Returns:
      The ObjectInstantiator for the class