Class BeanPredicate<T>

java.lang.Object
org.apache.commons.beanutils2.BeanPredicate<T>
Type Parameters:
T - the type of the input to the predicate
All Implemented Interfaces:
Predicate<T>

public class BeanPredicate<T> extends Object implements Predicate<T>

Predicate implementation that applies the given Predicate to the result of calling the given property getter.

  • Constructor Details

    • BeanPredicate

      public BeanPredicate(String propertyName, Predicate<T> predicate)
      Constructs a BeanPredicate that applies the given Predicate to the named property value.
      Parameters:
      propertyName - the name of the property whose value is to be predicated, not null
      predicate - the Predicate to be applied, not null
  • Method Details

    • getPredicate

      Gets the Predicate to be applied to the value of the named property during test(Object).
      Returns:
      Predicate, not null
    • getPropertyName

      Gets the name of the property whose value is to be predicated. in the evaluation.
      Returns:
      the property name, not null
    • setPredicate

      public void setPredicate(Predicate<T> predicate)
      Sets the Predicate to be applied to the value of the named property during test(Object).
      Parameters:
      predicate - Predicate, not null
    • setPropertyName

      public void setPropertyName(String propertyName)
      Sets the name of the property whose value is to be predicated.
      Parameters:
      propertyName - the name of the property whose value is to be predicated, not null
    • test

      public boolean test(Object object)
      Evaluates the given object by applying the getPredicate() to a property value named by getPropertyName().
      Specified by:
      test in interface Predicate<T>
      Parameters:
      object - The object to test
      Returns:
      the result of the predicate evaluation
      Throws:
      IllegalArgumentException - when the property cannot be evaluated