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

com.github.anhem.testpopulator.internal.carrier.Carrier Maven / Gradle / Ivy

Go to download

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy