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

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

package autofixture.generators.collections;

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

import java.util.Collection;

/**
 * Created by grzes on 22.03.2017.
 */
public class EmptyCollectionsGenerator implements InstanceGenerator {
    @Override
    public  boolean appliesTo(final InstanceType clazz) {
        return
                clazz.isAssignableTo(Collection.class)
                        || Iterable.class.isAssignableFrom(clazz.getRawType());
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public  T next(final InstanceType type, final FixtureContract fixture) {
        final Collection collection = type.createCollection(0);
        return (T) collection;
    }

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy