public <T> void addManyTo(Collection<T> collection, Class<T> clazz, int count) { for (int i = 0; i < count; i++) { Object result = this.specimenCreator.create(clazz); if (result instanceof NoSpecimen) continue; collection.add((T) result); } }
public <T extends Collection<U>, U> T createCollection(Class<T> collectionType, Class<U> innerType, int size) { T collection = this.specimenCreator.create(collectionType); this.addManyTo(collection, innerType, size); return collection; }
public <T extends Map<U, V>, U, V> T createMap(Class<T> mapType, Class<U> keyType, Class<V> valueType, int size) { T map = this.specimenCreator.create(mapType); this.addManyTo(map, keyType, valueType, size); return map; } }