net.sf.molae.pipe.binop
Class SymmetricBinaryFunction<S,T>

java.lang.Object
  extended by net.sf.molae.pipe.binop.AbstractBinaryFunction<S,S,T>
      extended by net.sf.molae.pipe.binop.SymmetricBinaryFunction<S,T>
All Implemented Interfaces:
BinaryFunction<S,S,T>
Direct Known Subclasses:
ConstantBinaryFunction, Max, Min

public abstract class SymmetricBinaryFunction<S,T>
extends AbstractBinaryFunction<S,S,T>

Skeleton implementation of BinaryFunction for symmetric functions.


Constructor Summary
SymmetricBinaryFunction(String name, boolean associative, S identityElement, S sink)
          Constructs a new SymmetricBinaryFunction.
 
Method Summary
 S getIdentityElement()
          Returns the identity element of this function.
 S getSink()
          Returns the sink of this function.
protected  boolean isAnIdentityElement(Object obj)
          Tests if the specified element is the identity element of this function.
protected  boolean isASink(Object obj)
          Tests if the specified element is the sink of this function.
 
Methods inherited from class net.sf.molae.pipe.binop.AbstractBinaryFunction
compute, getFirstInverse, getPermuted, isAssociative, isLeftSink, isRightIdentityElement, setFirstInverse, setPermuted, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymmetricBinaryFunction

public SymmetricBinaryFunction(String name,
                               boolean associative,
                               S identityElement,
                               S sink)
Constructs a new SymmetricBinaryFunction.

Parameters:
name - the result of the AbstractBinaryFunction.toString() method
associative - this value is returned by the
identityElement - the identity element of this function null if no such element exists or is not known.
sink - the sink of this function null if no such element exists or is not known. AbstractBinaryFunction.isAssociative() method.
Method Detail

getIdentityElement

public S getIdentityElement()
Returns the identity element of this function. The identitiy element fulfils for every object a where compute is defined: a.equals(compute(getIdentityElement(), a)) and a.equals(compute(a, getIdentityElement())).

Returns:
the identity element of this function or null if no such element exists or is not known.
Throws:
UnsupportedOperationException - if not implemented

getSink

public S getSink()
Returns the sink of this function. The sink fulfils for every object a where compute is defined: getSink().equals(compute(getSink(), a)) and getSink().equals(compute(a, getSink())).

Returns:
the sink of this function or null if no such element exists or is not known.

isAnIdentityElement

protected final boolean isAnIdentityElement(Object obj)
Tests if the specified element is the identity element of this function. This implementation compares the specified element with the identity element of this function.

Overrides:
isAnIdentityElement in class AbstractBinaryFunction<S,S,T>
Parameters:
obj - the candidate for identity element
Returns:
true if the specified object is the identity element of this function.

isASink

protected final boolean isASink(Object obj)
Tests if the specified element is the sink of this function. This implementation compares the specified element with the sink of this function.

Overrides:
isASink in class AbstractBinaryFunction<S,S,T>
Parameters:
obj - the candidate for sink
Returns:
true if the specified object is the sink of this function.