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

autofixture.publicinterface.inline.strings.StringNotContainingSubstringsGenerator Maven / Gradle / Ivy

There is a newer version: 2.1.10
Show newest version
package autofixture.publicinterface.inline.strings;

import autofixture.interfaces.FixtureContract;
import autofixture.interfaces.InlineInstanceGenerator;

public class StringNotContainingSubstringsGenerator implements
    InlineInstanceGenerator {

  private final String[] excludedSubstrings;

  public StringNotContainingSubstringsGenerator(final String[] excludedSubstrings) {
    this.excludedSubstrings = excludedSubstrings.clone();
  }

  private static boolean thereAreAnyOccurencesOf(
      final String[] excludedSubstrings,
      final String result) {
    for (final String str : excludedSubstrings) {
      if (result.contains(str)) {
        return true;
      }
    }
    return false;
  }

  @Override
  public String next(final FixtureContract fixture) {
    String result;
    do {
      result = fixture.create(String.class);
    } while (thereAreAnyOccurencesOf(excludedSubstrings, result));
    return result;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy