Class SingleArgumentInvokableInstantiator<A,​R>

  • Type Parameters:
    A - the type of the constructor argument
    R - the type of the resulting instance
    All Implemented Interfaces:
    Instantiator<A,​R>
    Direct Known Subclasses:
    SingleArgumentConstructorInstantiator, SingleArgumentFactoryMethodInstantiator

    public abstract class SingleArgumentInvokableInstantiator<A,​R>
    extends java.lang.Object
    implements Instantiator<A,​R>
    Can instantiate a certain type of classes, which expect exactly one argument of a certain type in the constructor.

    This class is immutable and thus reusable and thread safe.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Class<R> instanceClass  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      <A1 extends A>
      R
      create​(A1 argument)
      Creates an instance, using the given argument.
      protected abstract com.google.common.reflect.Invokable<R,​R> invokableFor​(java.lang.Class<A> constructorArgumentClass)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • instanceClass

        protected final java.lang.Class<R> instanceClass
    • Constructor Detail

      • SingleArgumentInvokableInstantiator

        public SingleArgumentInvokableInstantiator​(java.lang.Class<R> instanceClass,
                                                   java.lang.Class<A> constructorArgumentClass)
    • Method Detail

      • create

        public <A1 extends AR create​(A1 argument)
        Description copied from interface: Instantiator
        Creates an instance, using the given argument.
        Specified by:
        create in interface Instantiator<A,​R>
        Parameters:
        argument - the argument used to create the new instance
        Returns:
        an instance of the respective type
      • invokableFor

        protected abstract com.google.common.reflect.Invokable<R,​R> invokableFor​(java.lang.Class<A> constructorArgumentClass)