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

autofixture.generators.RecursionGuarded Maven / Gradle / Ivy

package autofixture.generators;

import autofixture.interfaces.*;

public class RecursionGuarded implements GeneratorsPipeline {
  private final GeneratorsPipeline generatorsPipeline;
  private final RecursionGuard recursionGuard;

  public RecursionGuarded(final GeneratorsPipeline generatorsPipeline, final RecursionGuard recursionGuard) {
    this.generatorsPipeline = generatorsPipeline;
    this.recursionGuard = recursionGuard;
  }

  @Override
  public  T generateInstanceOf(final InstanceType instanceType, final FixtureContract fixture) {
    try {
      recursionGuard.addDepthLevelTo(instanceType);
      return recursionGuard.generateUsing(generatorsPipeline, instanceType, fixture);
    } finally {
      recursionGuard.removeDepthLevelFor(instanceType);
    }

  }

  @Override
  public  T generateEmptyInstanceOf(final InstanceType instanceType, final FixtureContract fixture) {
    return generatorsPipeline.generateEmptyInstanceOf(instanceType, fixture);
  }

  @Override
  public void registerCustomization(final InstanceGenerator instanceGenerator) {
    generatorsPipeline.registerCustomization(instanceGenerator);
  }

  @Override
  public void clearCustomizations() {
    generatorsPipeline.clearCustomizations();
  }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy