Class MapGeneratorSpecImpl<K,​V>

    • Constructor Detail

      • MapGeneratorSpecImpl

        public MapGeneratorSpecImpl​(GeneratorContext context)
    • Method Detail

      • generate

        public Map<K,​V> generate()
        Description copied from interface: Generator
        Depending on implementation, repeated invocations may return different values. Some implementations may return random values on each invocation, while others may return predefined values or random values from a given set.

        Generators can be passed in as a lambda function. The following example shows how to override generation strategy for certain fields.

        
             Person person = Instancio.of(Person.class)
                 .generate(field("age"), gen -> gen.oneOf(20, 30, 40, 50))
                 .supply(field("location"), () -> "Canada")
                 .supply(all(LocalDateTime.class), () -> LocalDateTime.now())
                 .create();
         
        Specified by:
        generate in interface Generator<K>
        Overrides:
        generate in class MapGenerator<K,​V>
        Returns:
        generated value
      • isDelegating

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

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

        public Class<?> targetType()