net.sf.staccatocommons.lang.predicate
Class Predicates

java.lang.Object
  extended by net.sf.staccatocommons.lang.predicate.Predicates

public class Predicates
extends Object

Factory methods for common predicates

Author:
flbulgarelli

Method Summary
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
all(net.sf.staccatocommons.defs.Evaluable<T>... predicates)
          Returns a predicate that evaluates to true if and only if all the given predicates evaluate true
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
all(Iterable<net.sf.staccatocommons.defs.Evaluable<T>> predicates)
          Returns a predicate that evaluates to true if and only if all the given predicates evaluate true
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
any(net.sf.staccatocommons.defs.Evaluable<T>... predicates)
          Returns a predicate that evaluates to false if and only if all the given predicates evaluate false
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
any(Iterable<net.sf.staccatocommons.defs.Evaluable<T>> predicates)
          Returns a predicate that evaluates to false if and only if all the given predicates evaluate false
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
equal(T value)
          Returns a predicate that tests if the given value is equal to its argument: value.equals(argument).
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
false_()
           
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
from(net.sf.staccatocommons.defs.Evaluable<? super T> evaluable)
          Converts the given Evaluable into a AbstractPredicate.
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
in(Collection<T> values)
          Returns a predicate that tests if its argument is equal to any of the values in the given collection
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
in(T... values)
          Returns a predicate that tests if its argument is equal to any of the given values
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
isInstanceOf(Class<? extends T> clazz)
          Returns a predicate that tests if its argument is instance of the given class
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
notNull()
          Returns a preficate that tests if its argument is not null
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
null_()
          Returns a predicate that tests if its argument is null
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
same(T value)
          Returns a predicate that tests if its argument is the same that the given value
static
<T> net.sf.staccatocommons.defs.predicate.Predicate<T>
true_()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

true_

@Constant
@NullSafe
public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> true_()
Type Parameters:
T -
Returns:
A AbstractPredicate that always returns true

false_

@Constant
@NullSafe
public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> false_()
Type Parameters:
T -
Returns:
A AbstractPredicate that always returns false

notNull

@Constant
@NullSafe
public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> notNull()
Returns a preficate that tests if its argument is not null

Type Parameters:
T -
Returns:
A constant AbstractPredicate

null_

@Constant
@NullSafe
public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> null_()
Returns a predicate that tests if its argument is null

Type Parameters:
T -
Returns:
A singleton AbstractPredicate

equal

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> equal(@NonNull
                                                                           T value)
Returns a predicate that tests if the given value is equal to its argument: value.equals(argument).

Type Parameters:
T -
Parameters:
value -
Returns:
Equiv.equal().apply(value)

same

@NullSafe
public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> same(T value)
Returns a predicate that tests if its argument is the same that the given value

Type Parameters:
T -
Parameters:
value -
Returns:
Equiv.same().apply(value)

isInstanceOf

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> isInstanceOf(@NonNull
                                                                                  Class<? extends T> clazz)
Returns a predicate that tests if its argument is instance of the given class

Type Parameters:
T -
Parameters:
clazz -
Returns:
a new AbstractPredicate

in

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> in(@NonNull
                                                                        T... values)
Returns a predicate that tests if its argument is equal to any of the given values

Type Parameters:
T -
Parameters:
values -
Returns:
a new Predicate

in

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> in(@NonNull
                                                                        Collection<T> values)
Returns a predicate that tests if its argument is equal to any of the values in the given collection

Type Parameters:
T -
Parameters:
values -
Returns:
a new AbstractPredicate

all

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> all(@NonNull
                                                                         net.sf.staccatocommons.defs.Evaluable<T>... predicates)
Returns a predicate that evaluates to true if and only if all the given predicates evaluate true

Type Parameters:
T -
Parameters:
predicates -
Returns:
the all predicate

all

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> all(@NonNull
                                                                         Iterable<net.sf.staccatocommons.defs.Evaluable<T>> predicates)
Returns a predicate that evaluates to true if and only if all the given predicates evaluate true

Type Parameters:
T -
Parameters:
predicates -
Returns:
the all predicate

any

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> any(@NonNull
                                                                         net.sf.staccatocommons.defs.Evaluable<T>... predicates)
Returns a predicate that evaluates to false if and only if all the given predicates evaluate false

Type Parameters:
T -
Parameters:
predicates -
Returns:
the any predicate

any

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> any(@NonNull
                                                                         Iterable<net.sf.staccatocommons.defs.Evaluable<T>> predicates)
Returns a predicate that evaluates to false if and only if all the given predicates evaluate false

Type Parameters:
T -
Parameters:
predicates -
Returns:
the any predicate

from

public static <T> net.sf.staccatocommons.defs.predicate.Predicate<T> from(@NonNull
                                                                          net.sf.staccatocommons.defs.Evaluable<? super T> evaluable)
Converts the given Evaluable into a AbstractPredicate. If it is already a Predicate, returns it.

Type Parameters:
T -
Parameters:
evaluable -
Returns:
a AbstractPredicate view of the given evaluable, or the evaluable, it is a AbstractPredicate already


Copyright © 2010-2012 Staccatocommons. All Rights Reserved.