net.sf.jga.fn.comparison
Class NotEqualTo<T>

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.BinaryFunctor<T,T,java.lang.Boolean>
          extended by net.sf.jga.fn.comparison.NotEqualTo<T>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class NotEqualTo<T>
extends BinaryFunctor<T,T,java.lang.Boolean>

Binary Predicate that returns TRUE for object arguments x and y when x != y using the built-in equals() method or an optional Comparator given at construction. By default, this object will not throw NullPointerException: it will return true if either runtime arguments is null but false if both are null. If an optional comparator is used, then its implementation will determine if a NullPointerException is thrown when passed a null argument.

To serialize an NotEqual functor, the comparator passed at construction(if any) must be Serializable.

Copyright © 2002-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface NotEqualTo.Visitor
          Interface for classes that may interpret a NotEqualTo predicate.
 
Constructor Summary
NotEqualTo()
          Builds an EqualTo that uses the built-in equals method.
NotEqualTo(java.util.Comparator<? super T> comp)
          Builds an EqualTo that uses the given comparator.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(NotEqualTo) method, if it implements the nested Visitor interface.
 java.lang.Boolean fn(T x, T y)
          Given arguments x and y, returns !(x.equals(y)).
 java.util.Comparator<? super T> getComparator()
          Returns the comparator in use by this functor, if any.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.BinaryFunctor
bind, bind0th, bind1st, bind2nd, bindNth, compose, compose, composeNth, distribute, eval, generate, generate1st, generate2nd, generateNth
 
Methods inherited from class net.sf.jga.fn.Functor
composeNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NotEqualTo

public NotEqualTo()
Builds an EqualTo that uses the built-in equals method.


NotEqualTo

public NotEqualTo(java.util.Comparator<? super T> comp)
Builds an EqualTo that uses the given comparator.

Method Detail

getComparator

public java.util.Comparator<? super T> getComparator()
Returns the comparator in use by this functor, if any.

Returns:
the comparator in use by this functor, if any.

fn

public java.lang.Boolean fn(T x,
                            T y)
Given arguments x and y, returns !(x.equals(y)). Will not throw NullPointerException if either x or y are null: will return true if either x or y (but not both) are null, will return false if both x and y are null.

Specified by:
fn in class BinaryFunctor<T,T,java.lang.Boolean>
Returns:
!(x.equals(y))

accept

public void accept(Visitor v)
Calls the Visitor's visit(NotEqualTo) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<java.lang.Boolean>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2006 David A. Hall. All Rights Reserved.