Class Factory<T,​R>

  • All Implemented Interfaces:
    MockUnit<T>

    public class Factory<T,​R>
    extends java.lang.Object
    implements MockUnit<T>
    • Constructor Detail

      • Factory

        public Factory​(java.lang.Class<T> targetClass,
                       java.lang.Class<R> factoryClass)
    • Method Detail

      • factory

        public static <T,​FT> Factory<T,​FT> factory​(java.lang.Class<T> targetClass,
                                                               java.lang.Class<FT> factoryClass)

        Returns a new Factory object that can be used to instantiate Java Objects by calling a static factory method and supplying it with arbitrary data.

        The Factory class implements MockUnit<T>.

        Type Parameters:
        T - The type of the target class
        FT - The type of the factory class
        Parameters:
        targetClass - The Java class we want to create instances of.
        factoryClass - The Java class that contains the static-factory method we want to invoke.
        Returns:
        The factory MockUnit
      • method

        public Factory<T,​R> method​(java.lang.String methodName)

        Specifies the static method name.

        Parameters:
        methodName - The method factory method used to instantiate the class.
        Returns:
        The same instance of the previously created Factory object. The Factory class implements the MockUnit<T> interface.
      • params

        public Factory<T,​R> params​(java.lang.Object... params)

        Specified the params that are going to be supplied to the static factory method.

        Note: If a MockUnit is supplied as a parameter the val() method is invoked instead of using the actual value.

        Parameters:
        params - A var-arg array being the list of params supplied to the factory method.
        Returns:
        The same instance of the Factory object. THe Factory class implements the MockUnit<T> interface.
      • supplier

        public java.util.function.Supplier<T> supplier()
        Description copied from interface: MockUnit
        This is the sole abstract method of the interface. Needs to be implemented every-time a MockUnit is implemented.
        Specified by:
        supplier in interface MockUnit<T>
        Returns:
        A Supplier<T>.