brooklyn.util.text.StringPredicates Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-utils-common Show documentation
Show all versions of brooklyn-utils-common Show documentation
Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else
package brooklyn.util.text;
import javax.annotation.Nullable;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
public class StringPredicates {
public static Predicate containsLiteralCaseInsensitive(final String fragment) {
return new Predicate() {
@Override
public boolean apply(@Nullable CharSequence input) {
return Strings.containsLiteralIgnoreCase(input, fragment);
}
};
}
public static Predicate containsLiteral(final String fragment) {
return new Predicate() {
@Override
public boolean apply(@Nullable CharSequence input) {
return Strings.containsLiteral(input, fragment);
}
};
}
public static Predicate containsRegex(final String regex) {
// "Pattern" ... what a bad name :)
return Predicates.containsPattern(regex);
}
// TODO globs, matches regex, etc ... add as you need them!
}