uk.co.jezuk.mango
Class Predicates

java.lang.Object
  extended by uk.co.jezuk.mango.Predicates

public class Predicates
extends java.lang.Object

The Mango Library Unary Predicates

A Predicate is a special form of a Function, whose result represents the truth or otherwise of some condition. Returns true if the condition the Predicate tests for is satisfied, false otherwise.

Author:
Jez Higgins, jez@jezuk.co.uk
See Also:
Predicate

Method Summary
static
<T> Predicate<T>
All(java.util.Collection<Predicate<T>> preds)
           
static
<T> Predicate<T>
All(java.util.Iterator<Predicate<T>> preds)
           
static
<T> Predicate<T>
All(java.lang.Object... preds)
          A Predicate which returns true if all of the supplied Predicates are true.
static
<T> Predicate<T>
And(Predicate<T> pred1, Predicate<T> pred2)
          A Predicate which returns the logical AND of two other Predicate.
static
<T> Predicate<T>
Any(java.util.Collection<Predicate<T>> preds)
           
static
<T> Predicate<T>
Any(java.util.Iterator<Predicate<T>> preds)
           
static
<T> Predicate<T>
Any(java.lang.Object... preds)
          A Predicate which returns true if any one of the supplied Predicates are true.
static
<T> Predicate<T>
Constant(boolean constant)
          A Predicate which returns a precomputed constant value
static
<T> Predicate<T>
False()
          A Predicate which always returns false
static
<T> Predicate<T>
IsNull()
          A Predicate which checks whether the passed object reference is null.
static
<T> Predicate<T>
Nand(Predicate<T> pred1, Predicate<T> pred2)
          A Predicate which returns the logical NAND of two other Predicate.
static
<T> Predicate<T>
Nor(Predicate<T> pred1, Predicate<T> pred2)
          A Predicate which returns the logical NOR of two other Predicate.
static
<T> Predicate<T>
Not(Predicate<T> pred)
          A Predicate which is the logical negation of some other Predicate.
static
<T> Predicate<T>
NotNull()
          A Predicate which checks whether the passed object reference is not null.
static
<T> Predicate<T>
OneOf(java.util.Collection<Predicate<T>> preds)
           
static
<T> Predicate<T>
OneOf(java.util.Iterator<Predicate<T>> preds)
           
static
<T> Predicate<T>
OneOf(java.lang.Object... preds)
          A Predicate which returns true if only one of the supplied Predicates is true.
static
<T> Predicate<T>
Or(Predicate<T> pred1, Predicate<T> pred2)
          A Predicate which returns the logical OR of two other Predicate.
static
<T> Predicate<T>
True()
          A Predicate which always returns true
static
<T> Predicate<T>
Xnor(Predicate<T> pred1, Predicate<T> pred2)
          A Predicate which returns the logical XNOR of two other Predicate.
static
<T> Predicate<T>
Xor(Predicate<T> pred1, Predicate<T> pred2)
          A Predicate which returns the logical XOR of two other Predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

True

public static <T> Predicate<T> True()
A Predicate which always returns true


False

public static <T> Predicate<T> False()
A Predicate which always returns false


Constant

public static <T> Predicate<T> Constant(boolean constant)
A Predicate which returns a precomputed constant value


Not

public static <T> Predicate<T> Not(Predicate<T> pred)
A Predicate which is the logical negation of some other Predicate. If n is a Not object, and pred is the Predicate it was constructed with, then n.test(x) returns !pred.test(x).


And

public static <T> Predicate<T> And(Predicate<T> pred1,
                                   Predicate<T> pred2)
A Predicate which returns the logical AND of two other Predicate. If a is an And object, constructed with pred1 and pred2, then a.test(x) returns pred1.test(x) && pred2.test(x)


Or

public static <T> Predicate<T> Or(Predicate<T> pred1,
                                  Predicate<T> pred2)
A Predicate which returns the logical OR of two other Predicate. If a is an Or object, constructed with pred1 and pred2, then a.test(x) returns pred1.test(x) || pred2.test(x)


Xor

public static <T> Predicate<T> Xor(Predicate<T> pred1,
                                   Predicate<T> pred2)
A Predicate which returns the logical XOR of two other Predicate.


Nand

public static <T> Predicate<T> Nand(Predicate<T> pred1,
                                    Predicate<T> pred2)
A Predicate which returns the logical NAND of two other Predicate. If a is an Nand object, constructed with pred1 and pred2, then a.test(x) returns !(pred1.test(x) && pred2.test(x))


Nor

public static <T> Predicate<T> Nor(Predicate<T> pred1,
                                   Predicate<T> pred2)
A Predicate which returns the logical NOR of two other Predicate. If a is an Nor object, constructed with pred1 and pred2, then a.test(x) returns !(pred1.test(x) || pred2.test(x))


Xnor

public static <T> Predicate<T> Xnor(Predicate<T> pred1,
                                    Predicate<T> pred2)
A Predicate which returns the logical XNOR of two other Predicate.


All

public static <T> Predicate<T> All(java.lang.Object... preds)
A Predicate which returns true if all of the supplied Predicates are true. It is an AND generalised to any number of arguments. The Predicates are evaluated in the order supplied. Evaluation is short circuited as soon as a predicate fails.


All

public static <T> Predicate<T> All(java.util.Collection<Predicate<T>> preds)

All

public static <T> Predicate<T> All(java.util.Iterator<Predicate<T>> preds)

Any

public static <T> Predicate<T> Any(java.lang.Object... preds)
A Predicate which returns true if any one of the supplied Predicates are true. It is an OR generalised to any number of arguments. The Predicates are evaluated in the order supplied. Evaluation short circuits as soon as a predicate returns true.


Any

public static <T> Predicate<T> Any(java.util.Collection<Predicate<T>> preds)

Any

public static <T> Predicate<T> Any(java.util.Iterator<Predicate<T>> preds)

OneOf

public static <T> Predicate<T> OneOf(java.lang.Object... preds)
A Predicate which returns true if only one of the supplied Predicates is true. The Predicates are evaluated in the order supplied. Execution will short circuit as soon as more than one Predicate has returned true.


OneOf

public static <T> Predicate<T> OneOf(java.util.Collection<Predicate<T>> preds)

OneOf

public static <T> Predicate<T> OneOf(java.util.Iterator<Predicate<T>> preds)

IsNull

public static <T> Predicate<T> IsNull()
A Predicate which checks whether the passed object reference is null.


NotNull

public static <T> Predicate<T> NotNull()
A Predicate which checks whether the passed object reference is not null.



Copyright 2002-2010 JezUK Ltd.