com.github.anhem.testpopulator.internal.carrier.Carrier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of test-populator Show documentation
Show all versions of test-populator Show documentation
Populate java classes with fixed or random data using reflection. Facilitates the creation of objects in tests.
The newest version!
package com.github.anhem.testpopulator.internal.carrier;
import com.github.anhem.testpopulator.internal.object.ObjectFactory;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
public abstract class Carrier {
protected final ObjectFactory objectFactory;
protected final List visited;
public static ClassCarrier initialize(Class clazz, ObjectFactory objectFactory) {
return new ClassCarrier<>(clazz, objectFactory, new ArrayList<>());
}
protected Carrier(ObjectFactory objectFactory, List visited) {
this.objectFactory = objectFactory;
this.visited = visited;
}
public ObjectFactory getObjectFactory() {
return objectFactory;
}
@SuppressWarnings("unchecked")
public CollectionCarrier toCollectionCarrier(Type type, Type[] typeArguments) {
return new CollectionCarrier<>((Class) type, typeArguments, objectFactory, visited);
}
}