![JAR search and dependency download from the Maven repository](/logo.png)
autofixture.generators.objects.implementationdetails.ReflectionInstanceField Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of autofixturegenerator Show documentation
Show all versions of autofixturegenerator Show documentation
An attempt to reimplement core features of a popular .NET anonymous value generator - AutoFixture - in
Java
package autofixture.generators.objects.implementationdetails;
import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InstanceField;
import autofixture.interfaces.InstanceType;
import com.google.common.reflect.TypeToken;
import java.lang.reflect.Field;
public class ReflectionInstanceField implements InstanceField {
private final Field field;
private final InstanceType instanceType;
private final T instance;
public ReflectionInstanceField(final Field field, final InstanceType instanceType, final T instance) {
this.field = field;
this.instanceType = instanceType;
this.instance = instance;
}
@Override
public TypeToken> resolveActualType() {
return instanceType.resolveActualTypeOf(field);
}
@Override
public void setValueUsing(final FixtureContract fixture) throws IllegalAccessException {
field.set(instance, fixture.create(resolveActualType()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy