jaggregate
Class UnaryPredicate<A>

java.lang.Object
  extended by jaggregate.UnaryPredicate<A>
Type Parameters:
A - a constraint on the allowable types for the predicate's argument.
All Implemented Interfaces:
UnaryCondition<A>

public abstract class UnaryPredicate<A>
extends Object
implements UnaryCondition<A>

A predicate that accepts one argument.

Version:
$Id: UnaryPredicate.java,v 1.6 2008/10/03 19:01:23 pholser Exp $
Author:
Paul Holser

Method Summary
 UnaryPredicate<A> and(UnaryPredicate<? super A> other)
          Answers a predicate that represents the logical conjunction of this predicate and another predicate.
 String describe()
          Gives a string that describes the kinds of objects which match this predicate.
 UnaryPredicate<A> not()
          Answers a predicate that represents the logical inverse of this predicate; wherever this predicate's matches method would answer true, the inverse answers false; and vice versa.
static
<T> UnaryPredicate<T>
not(UnaryPredicate<T> predicate)
          Answers a predicate that represents the logical inverse of the given predicate; wherever the given predicate's matches method would answer true, the inverse answers false; and vice versa.
 UnaryPredicate<A> or(UnaryPredicate<? super A> other)
          Answers a predicate that represents the logical disjunction of this predicate and another predicate.
 UnaryPredicate<A> xor(UnaryPredicate<? super A> other)
          Answers a predicate that represents the logical exclusive disjunction of this predicate and another predicate.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jaggregate.UnaryCondition
matches
 

Method Detail

not

public final UnaryPredicate<A> not()
Answers a predicate that represents the logical inverse of this predicate; wherever this predicate's matches method would answer true, the inverse answers false; and vice versa.

Returns:
the inverse of this predicate

not

public static <T> UnaryPredicate<T> not(UnaryPredicate<T> predicate)
Answers a predicate that represents the logical inverse of the given predicate; wherever the given predicate's matches method would answer true, the inverse answers false; and vice versa.

Type Parameters:
T - constraint on the types accepted by the predicate
Parameters:
predicate - the predicate to invert
Returns:
the inverse of predicate
Throws:
NullPointerException - if predicate is null

or

public final UnaryPredicate<A> or(UnaryPredicate<? super A> other)
Answers a predicate that represents the logical disjunction of this predicate and another predicate. The disjunction's matches method answers true if either this predicate or the other predicate would answer true.

When the disjunction is evaluated, this predicate is always evaluated first. The other predicate may not be evaluated; so do not depend on its evaluation for side effects.

Parameters:
other - the "right-hand" operand of the disjunction
Returns:
the logical disjunction of this predicate and other
Throws:
NullPointerException - if other is null

and

public final UnaryPredicate<A> and(UnaryPredicate<? super A> other)
Answers a predicate that represents the logical conjunction of this predicate and another predicate. The conjunction's matches method answers true if both this predicate and the other predicate would answer true.

When the conjunction is evaluated, this predicate is always evaluated first. The other predicate may not be evaluated; so do not depend on its evaluation for side effects.

Parameters:
other - the "right-hand" operand of the conjunction
Returns:
the logical conjunction of this predicate and other
Throws:
NullPointerException - if other is null

xor

public final UnaryPredicate<A> xor(UnaryPredicate<? super A> other)
Answers a predicate that represents the logical exclusive disjunction of this predicate and another predicate. The disjunction's matches method answers true if either this predicate or the other predicate, but not both, would answer true.

When the disjunction is evaluated, both this predicate and the other predicate will be evaluated.

Parameters:
other - the "right-hand" operand of the disjunction
Returns:
the logical exclusive disjunction of this predicate and other
Throws:
NullPointerException - if other is null

describe

public String describe()
Gives a string that describes the kinds of objects which match this predicate.

If not overridden, this method answers the same as Object.toString().

Returns:
a description of objects that meet this predicate's criteria


© Copyright 2004-2008 Paul R. Holser, Jr. All rights reserved. Licensed under the Academic Free License version 3.0. pholser@alumni.rice.edu