![JAR search and dependency download from the Maven repository](/logo.png)
autofixture.publicinterface.inline.ExplodingInstanceGenerator 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.publicinterface.inline;
import autofixture.exceptions.OnlyInterfacesAreSupportedException;
import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InlineInstanceGenerator;
import autofixture.publicinterface.inline.implementationdetails.ExplodingInstanceHandler;
import com.google.common.reflect.Reflection;
import com.google.common.reflect.TypeToken;
public class ExplodingInstanceGenerator implements InlineInstanceGenerator {
private final TypeToken instance;
public ExplodingInstanceGenerator(final TypeToken instance2) {
this.instance = instance2;
}
@SuppressWarnings("unchecked")
@Override
public T next(final FixtureContract fixture) {
if (instance.getRawType().isInterface()) {
return (T) Reflection.newProxy(instance.getRawType(),
new ExplodingInstanceHandler());
} else {
throw new OnlyInterfacesAreSupportedException(
"Exploding instances can be created out of interfaces only!");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy