Class RetrieveGenericsForDefaultAnswers
- java.lang.Object
-
- org.mockito.internal.stubbing.defaultanswers.RetrieveGenericsForDefaultAnswers
-
final class RetrieveGenericsForDefaultAnswers extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
RetrieveGenericsForDefaultAnswers.AnswerCallback
-
Field Summary
Fields Modifier and Type Field Description private static MockitoCore
MOCKITO_CORE
-
Constructor Summary
Constructors Modifier Constructor Description private
RetrieveGenericsForDefaultAnswers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.Object
delegateChains(java.lang.Class<?> type)
Try to resolve the result value usingReturnsEmptyValues
andReturnsMoreEmptyValues
.private static java.lang.Class<?>
findTypeFromGeneric(InvocationOnMock invocation, java.lang.reflect.TypeVariable returnType)
Retrieve the expected type when it came from a primitive.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.(package private) static java.lang.Object
returnTypeForMockWithCorrectGenerics(InvocationOnMock invocation, RetrieveGenericsForDefaultAnswers.AnswerCallback answerCallback)
-
-
-
Field Detail
-
MOCKITO_CORE
private static final MockitoCore MOCKITO_CORE
-
-
Method Detail
-
returnTypeForMockWithCorrectGenerics
static java.lang.Object returnTypeForMockWithCorrectGenerics(InvocationOnMock invocation, RetrieveGenericsForDefaultAnswers.AnswerCallback answerCallback)
-
delegateChains
private static java.lang.Object delegateChains(java.lang.Class<?> type)
Try to resolve the result value usingReturnsEmptyValues
andReturnsMoreEmptyValues
. 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 invocationreturnType
- 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 invocationreturnType
- the expected return type- Returns:
- the return type or null if the return type cannot be found
-
-