![JAR search and dependency download from the Maven repository](/logo.png)
autofixture.publicinterface.inline.strings.StringNotContainingSubstringsGenerator 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.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 - 2025 Weber Informatics LLC | Privacy Policy