Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

ArrayContainsPredicate CollectionContainsPredicate BeanPropertyValueEqualsPredicate 可以删除 #42

Closed
venusdrogon opened this issue Jul 6, 2016 · 2 comments
Assignees
Milestone

Comments

@venusdrogon
Copy link
Collaborator

#41 自从有了 BeanPredicateUtil

那么

ArrayContainsPredicate
CollectionContainsPredicate
BeanPropertyValueEqualsPredicate

3个类 可以删除

@venusdrogon venusdrogon added this to the 1.8.0 milestone Jul 6, 2016
@venusdrogon venusdrogon self-assigned this Jul 6, 2016
@venusdrogon
Copy link
Collaborator Author

3284c56

@venusdrogon
Copy link
Collaborator Author

以 匿名内部类的形式来实现

public final class BeanPredicateUtil{

    public static <T, V> Predicate<T> equalPredicate(String propertyName,V propertyValue){
        return new BeanPredicate<T>(propertyName, PredicateUtils.equalPredicate(propertyValue));
    }


    @SafeVarargs
    public static <T, V> Predicate<T> containsPredicate(final String propertyName,final V...propertyValues){
        return new BeanPredicate<T>(propertyName, new Predicate<V>(){

            @Override
            public boolean evaluate(V propertyValue){
                return org.apache.commons.lang3.ArrayUtils.contains(propertyValues, propertyValue);
            }
        });
    }


    public static <T, V> Predicate<T> containsPredicate(final String propertyName,final Collection<V> propertyValueList){
        return new BeanPredicate<T>(propertyName, new Predicate<V>(){

            @Override
            public boolean evaluate(V propertyValue){
                return isNullOrEmpty(propertyValueList) ? false : propertyValueList.contains(propertyValue);
            }
        });
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant