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

brooklyn.util.text.StringPredicates Maven / Gradle / Ivy

Go to download

Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else

There is a newer version: 0.7.0-M1
Show newest version
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!
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy