com.flextrade.jfixture.customisation.GreedyConstructorCustomisation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfixture Show documentation
Show all versions of jfixture Show documentation
JFixture is an open source library based on the popular .NET library, AutoFixture
package com.flextrade.jfixture.customisation;
import com.flextrade.jfixture.ConstructorQuery;
import com.flextrade.jfixture.DefaultConstructorQuery;
import com.flextrade.jfixture.JFixture;
import com.flextrade.jfixture.SpecimenBuilder;
import com.flextrade.jfixture.builders.ClassToConstructorRelay;
import com.flextrade.jfixture.specifications.SpecificTypeSpecification;
import com.flextrade.jfixture.utility.SpecimenType;
import com.flextrade.jfixture.utility.comparators.ConstructorParameterCountComparator;
import com.flextrade.jfixture.utility.comparators.InverseComparator;
import java.lang.reflect.Constructor;
import java.lang.reflect.Type;
public class GreedyConstructorCustomisation implements Customisation {
private final SpecimenType type;
private final ConstructorQuery mostParameterCountConstructorQuery;
public GreedyConstructorCustomisation(Type type) {
this.type = SpecimenType.of(type);
this.mostParameterCountConstructorQuery = new DefaultConstructorQuery(new InverseComparator>(new ConstructorParameterCountComparator()));
}
@Override
public void customise(JFixture fixture) {
SpecimenBuilder greedyConstructorRelay = new ClassToConstructorRelay(mostParameterCountConstructorQuery, new SpecificTypeSpecification(this.type));
fixture.addBuilderToStartOfPipeline(greedyConstructorRelay);
}
}