org.apache.commons.functor.core.composite
Class UnaryOr<A>

java.lang.Object
  extended by org.apache.commons.functor.core.composite.UnaryOr<A>
All Implemented Interfaces:
java.io.Serializable, Functor, UnaryFunctor<A>, UnaryPredicate<A>

public final class UnaryOr<A>
extends java.lang.Object

Tests true iff at least one of its children test true. Note that by this definition, the "or" of an empty collection of predicates tests false.

Note that although this class implements Serializable, a given instance will only be truly Serializable if all the underlying functors are. Attempts to serialize an instance whose delegates are not all Serializable will result in an exception.

Version:
$Revision: 665786 $ $Date: 2008-06-09 12:17:39 -0500 (Mon, 09 Jun 2008) $
Author:
Rodney Waldhoff
See Also:
Serialized Form

Constructor Summary
UnaryOr()
          Create a new UnaryOr.
UnaryOr(UnaryPredicate<? super A> p)
          Create a new UnaryOr.
UnaryOr(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q)
          Create a new UnaryOr.
UnaryOr(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q, UnaryPredicate<? super A> r)
          Create a new UnaryOr.
 
Method Summary
protected  void addUnaryPredicate(UnaryPredicate<? super A> p)
          Add a UnaryPredicate to the list
 boolean equals(java.lang.Object that)
          Indicates whether some other object is "equal to" this functor. This method must adhere to general Object.equals contract. Additionally, this method can return true only if the specified Object implements the same functor interface and is known to produce the same results and/or side-effects for the same arguments (if any).

While implementators are strongly encouraged to override the default Object implementation of this method, note that the default Object implementation does in fact adhere to the functor equals contract.

 boolean equals(UnaryOr<?> that)
          Learn whether another UnaryOr is equal to this.
protected  java.util.Iterator<UnaryPredicate<? super A>> getUnaryPredicateIterator()
          Get an Iterator over the contained UnaryPredicates.
protected  boolean getUnaryPredicateListEquals(org.apache.commons.functor.core.composite.BaseUnaryPredicateList<?> that)
          Learn whether another BaseUnaryPredicateList has content equal to this
protected  int getUnaryPredicateListHashCode()
          Get a hashCode for the list.
protected  java.lang.String getUnaryPredicateListToString()
          Get a toString for the list.
 int hashCode()
          Returns a hash code for this functor adhering to the general Object.hashCode contract. Implementators are strongly encouraged but not strictly required to override the default Object implementation of this method.
 UnaryOr<A> or(UnaryPredicate<? super A> p)
          Fluently add a Predicate.
 boolean test(A a)
          Evaluate this predicate.
 java.lang.String toString()
          Returns a human readable description of this functor. Implementators are strongly encouraged but not strictly required to override the default Object implementation of this method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnaryOr

public UnaryOr()
Create a new UnaryOr.


UnaryOr

public UnaryOr(UnaryPredicate<? super A> p)
Create a new UnaryOr.

Parameters:
p - Predicate to add

UnaryOr

public UnaryOr(UnaryPredicate<? super A> p,
               UnaryPredicate<? super A> q)
Create a new UnaryOr.

Parameters:
p - Predicate to add
q - Predicate to add

UnaryOr

public UnaryOr(UnaryPredicate<? super A> p,
               UnaryPredicate<? super A> q,
               UnaryPredicate<? super A> r)
Create a new UnaryOr.

Parameters:
p - Predicate to add
q - Predicate to add
r - Predicate to add
Method Detail

or

public UnaryOr<A> or(UnaryPredicate<? super A> p)
Fluently add a Predicate.

Parameters:
p - Predicate to add
Returns:
this

test

public boolean test(A a)
Evaluate this predicate.

Parameters:
a - the A object to test
Returns:
the result of this test

equals

public boolean equals(java.lang.Object that)
Indicates whether some other object is "equal to" this functor. This method must adhere to general Object.equals contract. Additionally, this method can return true only if the specified Object implements the same functor interface and is known to produce the same results and/or side-effects for the same arguments (if any).

While implementators are strongly encouraged to override the default Object implementation of this method, note that the default Object implementation does in fact adhere to the functor equals contract.

Specified by:
equals in interface Functor
Parameters:
that - the object to compare this functor to
Returns:
true iff the given object implements this functor interface, and is known to produce the same results and/or side-effects for the same arguments (if any).
See Also:
Functor.hashCode()

equals

public boolean equals(UnaryOr<?> that)
Learn whether another UnaryOr is equal to this.

Parameters:
that - UnaryOr to test
Returns:
boolean

hashCode

public int hashCode()
Returns a hash code for this functor adhering to the general Object.hashCode contract. Implementators are strongly encouraged but not strictly required to override the default Object implementation of this method.

Specified by:
hashCode in interface Functor
Returns:
a hash code for this functor
See Also:
Functor.equals(java.lang.Object)

toString

public java.lang.String toString()
Returns a human readable description of this functor. Implementators are strongly encouraged but not strictly required to override the default Object implementation of this method.

Specified by:
toString in interface Functor
Returns:
a human readable description of this functor

addUnaryPredicate

protected void addUnaryPredicate(UnaryPredicate<? super A> p)
Add a UnaryPredicate to the list

Parameters:
p - UnaryPredicate to add

getUnaryPredicateIterator

protected java.util.Iterator<UnaryPredicate<? super A>> getUnaryPredicateIterator()
Get an Iterator over the contained UnaryPredicates.

Returns:
Iterator

getUnaryPredicateListEquals

protected boolean getUnaryPredicateListEquals(org.apache.commons.functor.core.composite.BaseUnaryPredicateList<?> that)
Learn whether another BaseUnaryPredicateList has content equal to this

Parameters:
that - the BaseUnaryPredicateList to test
Returns:
boolean

getUnaryPredicateListHashCode

protected int getUnaryPredicateListHashCode()
Get a hashCode for the list.

Returns:
int

getUnaryPredicateListToString

protected java.lang.String getUnaryPredicateListToString()
Get a toString for the list.

Returns:
String


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.