Class OfMapApiImpl<K,V,M extends Map<K,V>>

All Implemented Interfaces:
InstancioApi<M>, InstancioOfClassApi<M>, InstancioOfCollectionApi<M>

public final class OfMapApiImpl<K,V,M extends Map<K,V>> extends OfClassApiImpl<M> implements InstancioOfCollectionApi<M>
  • Constructor Details

    • OfMapApiImpl

      public OfMapApiImpl(Class<M> mapType, Class<K> keyType, Class<V> valueType)
  • Method Details

    • size

      public InstancioOfCollectionApi<M> size(int size)
      Description copied from interface: InstancioOfCollectionApi
      Specifies collection size to generate.

      This method is syntactic sugar for:

      
         List<Integer> result = Instancio.ofList(Integer.class)
             .generate(root(), gen -> gen.collection().size(50))
             .create();
       

      Therefore, if you modify the collection generator via root() selector (for example, to specify the collection's type) then you will need to specify the size using the generator as well.

      For example, instead of:

      
         List<Integer> result = Instancio.ofList(Integer.class)
             .size(50)
             .generate(root(), gen -> gen.collection().subtype(LinkedList.class))
             .create();
       

      use:

      
         List<Integer> result = Instancio.ofList(Integer.class)
             .generate(root(), gen -> gen.collection().subtype(LinkedList.class).size(50))
             .create();
       
      Specified by:
      size in interface InstancioOfCollectionApi<K>
      Parameters:
      size - of the collection to generate
      Returns:
      API builder reference