Package org.instancio

Interface Generator<T>

    • Method Detail

      • generate

        T generate()
        Returns a generated value. By default, generated values are random.

        Generation parameters for common types such as strings, numbers, collections, etc. can be customised by passing in custom generators.

        Returns:
        generated value
      • isDelegating

        default boolean isDelegating()
        If true, then this generator delegate object instantiation to another generator supplied via setDelegate(Generator).
        Returns:
        true if this is a delegating generator
      • setDelegate

        default void setDelegate​(Generator<?> delegate)
        Set a delegate that will be responsible for instantiating an object on behalf of this generator.
        Parameters:
        delegate - that will create the target object
      • targetClass

        default Optional<Class<?>> targetClass()
        Target class to generate.

        If Optional.empty() is returned, it will default to the field type for fields, and element type for collection and array elements.

        If the type is an interface, such as Set, will generate a default implementation class such as HashSet.

        Returns:
        target class
      • getHints

        default GeneratedHints getHints()
        Returns hints, including collection sizes and whether values are nullable.
        Returns:
        generated hints