Example usage for org.apache.commons.collections4 PredicateUtils orPredicate

List of usage examples for org.apache.commons.collections4 PredicateUtils orPredicate

Introduction

In this page you can find the example usage for org.apache.commons.collections4 PredicateUtils orPredicate.

Prototype

public static <T> Predicate<T> orPredicate(final Predicate<? super T> predicate1,
        final Predicate<? super T> predicate2) 

Source Link

Document

Create a new Predicate that returns true if either of the specified predicates are true.

Usage

From source file:com.feilong.core.lang.reflect.FieldUtil.java

/**
 *  <code>klass</code> ? <code>excludeFieldNames</code> ?list.
 *
 * @param klass/* ww w.  ja  va  2  s  .c om*/
 *            the klass
 * @param excludeFieldNames
 *            ?field names,?nullOrEmpty ?
 * @return  <code>obj</code> null, {@link NullPointerException}<br>
 *          {@link FieldUtils#getAllFieldsList(Class)} nullempty, {@link Collections#emptyList()}<br>
 * @see FieldUtils#getAllFieldsList(Class)
 * @since 1.7.1
 */
//no static
public static List<Field> getAllFieldList(final Class<?> klass, String... excludeFieldNames) {
    // {@link Field},parents, public/protect/private/inherited...
    List<Field> fieldList = FieldUtils.getAllFieldsList(klass);
    if (isNullOrEmpty(fieldList)) {
        return Collections.emptyList();
    }
    //**********************************************************************************************
    Predicate<Field> excludeFieldPredicate = BeanPredicateUtil.containsPredicate("name", excludeFieldNames);
    Predicate<Field> staticPredicate = new Predicate<Field>() {

        @Override
        public boolean evaluate(Field field) {
            int modifiers = field.getModifiers();
            // ??? log   serialVersionUID
            boolean isStatic = Modifier.isStatic(modifiers);

            String pattern = "[{}.{}],modifiers:[{}]{}";
            LOGGER.trace(pattern, klass.getSimpleName(), field.getName(), modifiers,
                    isStatic ? " [isStatic]" : EMPTY);
            return isStatic;
        }
    };
    return CollectionsUtil.selectRejected(fieldList,
            PredicateUtils.orPredicate(excludeFieldPredicate, staticPredicate));
}