Interface TargetedGenerator<T>

Type Parameters:
T - The type of the target
All Known Implementing Classes:
AbstractTargetedGenerator, ConstructorParameterTypeGenerator, MethodParameterTypeGenerator, MethodReturnTypeGenerator, ParameterTypeGenerator, PropertyTypeGenerator

@API(status=EXPERIMENTAL, since="0.1") public interface TargetedGenerator<T>
Interface for generators that target a property, method or constructor parameter or method return type.
Since:
0.1
Version:
1.0, 2022-11
Author:
(w) Iker Hernaez
  • Method Summary

    Modifier and Type
    Method
    Description
    defaultValue(@NotNull Class<?>... groups)
    Returns the default value of the supported type.
    @NotNull Object[]
    getParameterSources(@NotNull Class<?>... groups)
    Returns the generation parameter sources to be used.
    nullableDefaultValue(@NotNull Class<?>... groups)
    Returns the default value for the specified type allowing null values.
    nullableRandomValue(@NotNull Class<?>... groups)
    Returns a random value of the specified type.
    randomValue(@NotNull Class<?>... groups)
    Returns a random value of the supported type.
  • Method Details

    • getParameterSources

      @NotNull @NotNull Object[] getParameterSources(@NotNull @NotNull Class<?>... groups)
      Returns the generation parameter sources to be used.

      The specified validation groups will be used to retrieve the constraints to use as sources.

      Parameters:
      groups - The validation groups.
      Returns:
      The generation parameter sources.
    • defaultValue

      @NotNull T defaultValue(@NotNull @NotNull Class<?>... groups)
      Returns the default value of the supported type.

      If the generator for the type of the target is a ParameterizableGenerator extracts the parameters from the constraints of the target when applying the specified validation groups.

      Parameters:
      groups - The validation groups to use when extracting the constraints of the target.
      Returns:
      The default value.
    • nullableDefaultValue

      T nullableDefaultValue(@NotNull @NotNull Class<?>... groups)
      Returns the default value for the specified type allowing null values.

      If the generator for the type of the target is a ParameterizableGenerator extracts the parameters from the constraints of the target when applying the specified validation groups.

      This method should return null except for native types or targets annotated with NotNull.

      Parameters:
      groups - The validation groups to use when extracting the constraints of the target.
      Returns:
      The nullable default value for the specified type.
    • randomValue

      @NotNull T randomValue(@NotNull @NotNull Class<?>... groups)
      Returns a random value of the supported type.

      If the generator for the type of the target is a ParameterizableGenerator extracts the parameters from the constraints of the target when applying the specified validation groups.

      Parameters:
      groups - The validation groups to use when extracting the constraints of the target
      Returns:
      A random value.
    • nullableRandomValue

      T nullableRandomValue(@NotNull @NotNull Class<?>... groups)
      Returns a random value of the specified type.

      If the generator for the type of the target is a ParameterizableGenerator extracts the parameters from the constraints of the target when applying the specified validation groups.

      The returned value has a probability of be null except for native types or targets annotated with NotNull. If not null behaves as randomValue().

      Parameters:
      groups - The validation groups to use when extracting the constraints of the target.
      Returns:
      A random nullable value.
      See Also: