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

autofixture.generators.objects.InterfaceImplementationGenerator Maven / Gradle / Ivy

package autofixture.generators.objects;

import autofixture.generators.objects.implementationdetails.InterfaceHandler;
import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InstanceGenerator;
import autofixture.interfaces.InstanceType;
import com.google.common.reflect.Reflection;

public class InterfaceImplementationGenerator implements InstanceGenerator {

  @Override
  public  boolean appliesTo(final InstanceType instanceType) {
    final boolean isInterface = instanceType.isInterface();
    return isInterface;
  }

  @Override
  @SuppressWarnings("unchecked")
  public  T next(final InstanceType instanceType, final FixtureContract fixture) {
    final Object proxy = Reflection.newProxy(instanceType.getRawType(), new InterfaceHandler(
        fixture, instanceType));
    return (T) proxy;
  }

  @Override
  public void setOmittingAutoProperties(final boolean isOn) {
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy