Package br.com.six2six.fixturefactory.function.impl

Source Code of br.com.six2six.fixturefactory.function.impl.EnumFunction

package br.com.six2six.fixturefactory.function.impl;

import java.util.ArrayList;
import java.util.List;

import br.com.six2six.fixturefactory.function.AtomicFunction;

public class EnumFunction implements AtomicFunction {
 
  private Class<? extends Enum<?>> clazz;
  private int quantity;
 
  public EnumFunction(Class<? extends Enum<?>> clazz, int quantity) {
    this.clazz = clazz;
    this.quantity = quantity;
  }
 
  @SuppressWarnings("unchecked")
  @Override
  public <T> T generateValue() {
    List<T> results = new ArrayList<T>();
    AtomicFunction function = new RandomFunction(clazz);
    for (int i = 0; i < quantity; i++) {
      results.add((T) function.generateValue());
    }
   
    return (T) results;
  }
}
TOP

Related Classes of br.com.six2six.fixturefactory.function.impl.EnumFunction

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.