Class RetrieveGenericsForDefaultAnswers


  • final class RetrieveGenericsForDefaultAnswers
    extends java.lang.Object
    • Field Detail

      • MOCKITO_CORE

        private static final MockitoCore MOCKITO_CORE
    • Constructor Detail

      • RetrieveGenericsForDefaultAnswers

        private RetrieveGenericsForDefaultAnswers()
    • Method Detail

      • delegateChains

        private static java.lang.Object delegateChains​(java.lang.Class<?> type)
        Try to resolve the result value using ReturnsEmptyValues and ReturnsMoreEmptyValues. This will try to use all parent class (superclass & interfaces) to retrieve the value..
        Parameters:
        type - the return type of the method
        Returns:
        a non-null instance if the type has been resolve. Null otherwise.
      • findTypeFromGeneric

        private static java.lang.Class<?> findTypeFromGeneric​(InvocationOnMock invocation,
                                                              java.lang.reflect.TypeVariable returnType)
        Retrieve the expected type when it came from a primitive. If the type cannot be retrieve, return null.
        Parameters:
        invocation - the current invocation
        returnType - the expected return type
        Returns:
        the type or null if not found
      • findTypeFromGenericInArguments

        private static java.lang.Class<?> findTypeFromGenericInArguments​(InvocationOnMock invocation,
                                                                         java.lang.reflect.TypeVariable returnType)
        Find a return type using generic arguments provided by the calling method.
        Parameters:
        invocation - the current invocation
        returnType - the expected return type
        Returns:
        the return type or null if the return type cannot be found