Package org.instancio
Interface InstancioCollectionsApi<C>
- Type Parameters:
C- collection type to create
- All Superinterfaces:
BaseApi<C>,InstancioApi<C>,LenientModeApi,SettingsApi,VerboseModeApi
Instancio API for generating collections populated with random data.
- Since:
- 2.0.0
-
Method Summary
Methods inherited from interface org.instancio.InstancioApi
applyFeed, applyFeed, as, asResult, assign, create, filter, generate, generate, ignore, lenient, onComplete, set, setBlank, setModel, stream, subtype, supply, supply, toModel, verbose, withMaxDepth, withNullable, withSeed, withSetting, withSettings, withUnique
-
Method Details
-
size
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();- Parameters:
size- of the collection to generate- Returns:
- API builder reference
- Since:
- 2.0.0
-