Java Code Examples for org.osgl.Lang#Predicate

The following examples show how to use org.osgl.Lang#Predicate . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StrTestBase.java    From java-tool with Apache License 2.0 5 votes vote down vote up
private static $.Predicate<Character> charIsIn(final char ... ca) {
    return new Lang.Predicate<Character>() {
        @Override
        public boolean test(Character character) {
            for (char c: ca) {
                if (character == c) return true;
            }
            return false;
        }
    };
}
 
Example 2
Source File: StrTestBase.java    From java-tool with Apache License 2.0 5 votes vote down vote up
private static $.Predicate<Character> charIsNotIn(final char ... ca) {
    return new Lang.Predicate<Character>() {
        @Override
        public boolean test(Character character) {
            for (char c: ca) {
                if (character == c) return false;
            }
            return true;
        }
    };
}
 
Example 3
Source File: C.java    From java-tool with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a function that remove all elements in the argument collection from
 * the {@code fromCollection} specified. The function returns {@code true} if
 * the fromCollection changed as a result of call
 * @param fromCollection the collection from which elements will be removed
 * @param <T> the element type
 * @return the function
 * @see Collection#removeAll(Collection)
 * @see #removeAll(Collection)
 */
@SuppressWarnings("unused")
public static <T> $.Predicate<Collection<? extends T>> removeAllFrom(final Collection<? super T> fromCollection) {
    return new Lang.Predicate<Collection<? extends T>>() {
        @Override
        public boolean test(Collection<? extends T> theCollection) {
            return fromCollection.removeAll(theCollection);
        }
    };
}
 
Example 4
Source File: C.java    From java-tool with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a function that remove all elements in the {@code source} collection from the
 * argument collection. The function returns {@code true} if the argument collection changed
 * as a result of call
 * @param source the collection in which elements will be used to remove from argument collection
 * @param <T> the element type
 * @return the function
 * @see Collection#removeAll(Collection)
 * @see #removeAllFrom(Collection)
 */
public static <T> $.Predicate<Collection<? super T>> removeAll(final Collection<? extends T> source) {
    return new Lang.Predicate<Collection<? super T>>() {
        @Override
        public boolean test(Collection<? super T> collection) {
            return collection.removeAll(source);
        }
    };
}