Class RetrieveGenericsForDefaultAnswers

java.lang.Object
org.mockito.internal.stubbing.defaultanswers.RetrieveGenericsForDefaultAnswers

final class RetrieveGenericsForDefaultAnswers extends Object
  • Field Details

    • MOCKITO_CORE

      private static final MockitoCore MOCKITO_CORE
  • Constructor Details

    • RetrieveGenericsForDefaultAnswers

      private RetrieveGenericsForDefaultAnswers()
  • Method Details

    • returnTypeForMockWithCorrectGenerics

      static Object returnTypeForMockWithCorrectGenerics(InvocationOnMock invocation, RetrieveGenericsForDefaultAnswers.AnswerCallback answerCallback)
    • delegateChains

      private static Object delegateChains(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 Class<?> findTypeFromGeneric(InvocationOnMock invocation, 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 Class<?> findTypeFromGenericInArguments(InvocationOnMock invocation, 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