Class CollectionGeneratorUtils

java.lang.Object
dev.orne.test.rnd.generators.CollectionGeneratorUtils

@API(status=EXPERIMENTAL, since="0.1") public final class CollectionGeneratorUtils extends Object
Utility class for generating components for generic types.
Since:
0.1
Version:
1.0, 2022-12
Author:
(w) Iker Hernaez
  • Method Details

    • randomComponent

      @NotNull public static @NotNull Object randomComponent(@NotNull @NotNull Type type)
      Returns a random value of the specified type.
      Parameters:
      type - The requested value type.
      Returns:
      A random value for the specified type.
      Throws:
      GeneratorNotFoundException - If no generator supports the requested value type.
      GeneratorNotParameterizableException - If the component type is a parameterized type and the generator registered for the raw class is not parameterizable.
    • nullableRandomComponent

      @NotNull public static @NotNull Object nullableRandomComponent(@NotNull @NotNull Type type)
      Returns a random value of the specified type allowing null values.

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

      Parameters:
      type - The requested value type.
      Returns:
      A random nullable value for the specified type.
      Throws:
      GeneratorNotFoundException - If no generator supports the requested value type.
      GeneratorNotParameterizableException - If the component type is a parameterized type and the generator registered for the raw class is not parameterizable.