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

autofixture.publicinterface.inline.GenerationConstrainedByValueRejection Maven / Gradle / Ivy

The newest version!
package autofixture.publicinterface.inline;

import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InlineConstrainedGenerator;
import autofixture.publicinterface.constraints.GenerationConstraint;
import com.google.common.reflect.TypeToken;

public class GenerationConstrainedByValueRejection implements InlineConstrainedGenerator {

  private final GenerationConstraint constraint;

  public GenerationConstrainedByValueRejection(final GenerationConstraint constraint) {
    this.constraint = constraint;
  }

  @Override
  public T next(final TypeToken typeToken, final FixtureContract fixture) {
    T currentValue;
    do {
      currentValue = fixture.create(typeToken);
    } while (constraint.doesNotAccept(currentValue));
    return currentValue;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy