Package org.instancio.junit
Interface GivenProvider.ElementContext
- Enclosing interface:
GivenProvider
@ExperimentalApi
public static interface GivenProvider.ElementContext
-
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
Returns the annotated element (either aFieldorParameter) for which an object instance is being provided.- Returns:
- the annotated element
- Since:
- 5.0.0
-
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
-