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 Type
    Method
    Description
    <A extends Annotation>
    A
    getAnnotation(Class<A> annotationType)
    Returns an annotation of the specified type, if present.
    Returns the class of the element for which an instance is being provided.
    Returns the annotated element (either a Field or Parameter) for which an object instance is being provided.
    Returns the type of the element for which an instance is being provided.
    org.instancio.Random
    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

      @ExperimentalApi AnnotatedElement getTargetElement()
      Returns the annotated element (either a Field or Parameter) for which an object instance is being provided.
      Returns:
      the annotated element
      Since:
      5.0.0
    • getTargetType

      @ExperimentalApi Type getTargetType()
      Returns the type of the element for which an instance is being provided. The type is:
      Returns:
      the type of object to be provided
      Since:
      5.0.0
      See Also:
    • getTargetClass

      @ExperimentalApi Class<?> 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

      @ExperimentalApi <A extends Annotation> A getAnnotation(Class<A> annotationType)
      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