Interface GivenProvider.ElementContext
- Enclosing interface:
GivenProvider
@ExperimentalApi
public static interface GivenProvider.ElementContext
An interface representing the context of an element
(either a
Field or Parameter)
for which an object instance is being provided.- Since:
- 5.0.0
-
Method Summary
Modifier and TypeMethodDescription<A extends Annotation>
AgetAnnotation(Class<A> annotationType) Returns an annotation of the specified type, if present.Class<?> Returns the class of the element for which an instance is being provided.Returns the type of the element for which an instance is being provided.org.instancio.Randomrandom()Returns the random instance used by Instancio to generate data.
-
Method Details
-
random
@ExperimentalApi org.instancio.Random random()Returns the random instance used by Instancio to generate data.Using this instance ensures that data will be reproducible.
- Returns:
- the random instance
- Since:
- 5.0.0
-
getTargetElement
-
getTargetType
Returns the type of the element for which an instance is being provided. The type is:Field.getGenericType()for fieldsParameter.getParameterizedType()for parameters
- Returns:
- the type of object to be provided
- Since:
- 5.0.0
- See Also:
-
getTargetClass
Returns the class of the element for which an instance is being provided.- Returns:
- the class of object to be provided
- Since:
- 5.0.0
- See Also:
-
getAnnotation
Returns an annotation of the specified type, if present.- Parameters:
annotationType- the type of the annotation to retrieve- Returns:
- the annotation if present, otherwise
null - Throws:
org.instancio.exception.InstancioApiException- is more than one annotation of the specified type is found- Since:
- 5.0.0
-