Package org.hivedb.util.classgen

Source Code of org.hivedb.util.classgen.GenerateInstanceCollection

package org.hivedb.util.classgen;

import org.hivedb.util.PrimitiveUtils;
import org.hivedb.util.functional.Generate;
import org.hivedb.util.functional.Generator;
import org.hivedb.util.functional.NumberIterator;

import java.util.Collection;

public class GenerateInstanceCollection<T> implements Generator<Collection<T>> {
  private Class<T> collectionItemClazz;
  private int size;
  public GenerateInstanceCollection(Class<T> collectionItemClazz, int size)
  {
    this.collectionItemClazz = collectionItemClazz;
    this.size = size;
  }
  @SuppressWarnings("unchecked")
  public Collection<T> generate() {
    return PrimitiveUtils.isPrimitiveClass(collectionItemClazz)
      ? new GeneratePrimitiveCollection(collectionItemClazz, size).generate()
      : Generate.create(new GenerateInstance<T>(this.collectionItemClazz), new NumberIterator(size));
  }
}
TOP

Related Classes of org.hivedb.util.classgen.GenerateInstanceCollection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.