All Downloads are FREE. Search and download functionalities are using the official Maven repository.

autofixture.generators.collections.ArrayGenerator Maven / Gradle / Ivy

package autofixture.generators.collections;

import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InstanceGenerator;
import autofixture.interfaces.InstanceType;

public class ArrayGenerator implements InstanceGenerator {

  @Override
  public  boolean appliesTo(final InstanceType clazz) {
    return clazz.isArray();
  }

  @SuppressWarnings("unchecked")
  @Override
  public  T next(final InstanceType type, final FixtureContract fixture) {
    final InstanceType componentType = type.getArrayElementType();
    final Object array = componentType.createArray(fixture.createMany(componentType).toArray());
    final T stronglyTypedArray = (T) array;
    return stronglyTypedArray;
  }

  @Override
  public  T nextEmpty(final InstanceType instanceType, final FixtureContract fixture) {
    final InstanceType componentType = instanceType.getArrayElementType();
    final Object array = componentType.createEmptyArray();
    final T stronglyTypedArray = (T) array;
    return stronglyTypedArray;
  }

  @Override
  public void setOmittingAutoProperties(final boolean isOn) {
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy