jaggregate
Class BinaryPredicate<A1,A2>

java.lang.Object
  extended by jaggregate.BinaryPredicate<A1,A2>
Type Parameters:
A1 - a constraint on the allowable types for the predicate's first argument
A2 - a constraint on the allowable types for the predicate's second argument
All Implemented Interfaces:
BinaryCondition<A1,A2>

public abstract class BinaryPredicate<A1,A2>
extends Object
implements BinaryCondition<A1,A2>

A predicate that accepts two arguments.

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

Method Summary
 BinaryPredicate<A1,A2> and(BinaryPredicate<? super A1,? super A2> other)
          Answers a predicate that represents the logical conjunction of this predicate and another predicate.
 UnaryPredicate<A2> bindFirst(A1 boundArgument)
          Answers a predicate of one argument that matches in the same manner as this predicate would if evaluated using a fixed first argument and another argument.
 UnaryPredicate<A1> bindSecond(A2 boundArgument)
          Answers a predicate of one argument that matches in the same manner as this predicate would if evaluated using a fixed second argument and another argument.
 String describe()
          Gives a string that describes the kinds of objects which match this predicate.
 BinaryPredicate<A1,A2> 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,U> BinaryPredicate<T,U>
not(BinaryPredicate<T,U> 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.
 BinaryPredicate<A1,A2> or(BinaryPredicate<? super A1,? super A2> other)
          Answers a predicate that represents the logical disjunction of this predicate and another predicate.
 BinaryPredicate<A1,A2> xor(BinaryPredicate<? super A1,? super A2> 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.BinaryCondition
matches
 

Method Detail

not

public final BinaryPredicate<A1,A2> 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,U> BinaryPredicate<T,U> not(BinaryPredicate<T,U> 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 first type accepted by the predicate
U - constraint on the second type accepted by the predicate
Parameters:
predicate - the predicate to invert
Returns:
the inverse of predicate
Throws:
NullPointerException - if predicate is null

or

public final BinaryPredicate<A1,A2> or(BinaryPredicate<? super A1,? super A2> 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

and

public final BinaryPredicate<A1,A2> and(BinaryPredicate<? super A1,? super A2> 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

xor

public final BinaryPredicate<A1,A2> xor(BinaryPredicate<? super A1,? super A2> 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

bindFirst

public final UnaryPredicate<A2> bindFirst(A1 boundArgument)
Answers a predicate of one argument that matches in the same manner as this predicate would if evaluated using a fixed first argument and another argument.

Parameters:
boundArgument - the fixed argument used as the first argument to this predicate's matches method
Returns:
a predicate that accepts one argument, of the same type as this predicate's second argument type, that behaves as this predicate would if always evaluated using boundArgument as the first argument

bindSecond

public final UnaryPredicate<A1> bindSecond(A2 boundArgument)
Answers a predicate of one argument that matches in the same manner as this predicate would if evaluated using a fixed second argument and another argument.

Parameters:
boundArgument - the fixed argument used as the second argument to this predicate's matches method
Returns:
a predicate that accepts one argument, of the same type as this predicate's first argument type, that behaves as this predicate would if always evaluated using boundArgument as the second argument

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