net.sf.molae.logic.basic
Class Commutator

java.lang.Object
  |
  +--net.sf.molae.pipe.basic.ObjectProxy
        |
        +--net.sf.molae.logic.basic.GeneralPredicateProxy
              |
              +--net.sf.molae.logic.basic.Commutator
All Implemented Interfaces:
GeneralPredicate, Predicate, ProxyProvider, SinglePredicate

public abstract class Commutator
extends GeneralPredicateProxy
implements SinglePredicate

This predicate proxy forwards all method calls to the corresponding method of the argument predicate.

Since:
1.1

Constructor Summary
Commutator(GeneralPredicate base)
          Creates a new Commutator for the specifed predicate.
 
Method Summary
abstract  GeneralPredicate andNot(GeneralPredicate p)
          Returns the difference of this predicate and the specified predicate.
protected  void checkArgument(GeneralPredicate p)
          Checks if the specified predicate can be handled by this proxy.
protected  Object compute(BinaryFunction operator, GeneralPredicate p)
          Placeholder for common implementation of all binary operations.
 GeneralPredicate copy()
          Creates and returns a copy of this object.
 boolean implies(GeneralPredicate p)
          Tests if this predicate implies the specified predicate.
 
Methods inherited from class net.sf.molae.logic.basic.GeneralPredicateProxy
and, className, evaluate, getBasePredicate, getProxyFor, implies, isEmpty, not, or, toString, xor
 
Methods inherited from class net.sf.molae.pipe.basic.ObjectProxy
assertNotNull, equals, getBase, hashCode, toVerboseString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.molae.logic.basic.SinglePredicate
and, not, or, xor
 
Methods inherited from interface net.sf.molae.logic.basic.GeneralPredicate
equals, evaluate, isEmpty
 

Constructor Detail

Commutator

public Commutator(GeneralPredicate base)
Creates a new Commutator for the specifed predicate.
Parameters:
base - the adapted predicate
Method Detail

checkArgument

protected void checkArgument(GeneralPredicate p)
Checks if the specified predicate can be handled by this proxy. This implementation checks if the specified predicate is a SinglePredicate.
Parameters:
p - predicate to be conjoined with this predicate
Throws:
IllegalArgumentException - if the specified predicate cannot be handled by this proxy.
ClassCastException - if the specified predicate cannot be handled by this proxy.
NullPointerException - if p is null.

copy

public GeneralPredicate copy()
Description copied from interface: GeneralPredicate
Creates and returns a copy of this object.
Specified by:
copy in interface GeneralPredicate
Overrides:
copy in class GeneralPredicateProxy
Following copied from interface: net.sf.molae.logic.basic.GeneralPredicate
Returns:
a clone of this instance.

implies

public boolean implies(GeneralPredicate p)
Tests if this predicate implies the specified predicate. This implementation calls GeneralPredicateProxy.implies(GeneralPredicate, GeneralPredicate).
Specified by:
implies in interface GeneralPredicate
Overrides:
implies in class GeneralPredicateProxy
Parameters:
p - predicate to be checked for implication in this predicate
Returns:
true if this predicate implies the specified predicate.
Throws:
ClassCastException - if this method is not implemented for the specified predicate.
IllegalArgumentException - if this method is not implemented for the specified predicate.
NullPointerException - if p is null.

andNot

public abstract GeneralPredicate andNot(GeneralPredicate p)
Returns the difference of this predicate and the specified predicate.
Specified by:
andNot in interface SinglePredicate
Overrides:
andNot in class GeneralPredicateProxy
Parameters:
p - predicate to be conjoined with this predicate
Returns:
the difference of this predicate and the specified predicate.
Throws:
ClassCastException - if the difference of the base predicate and the specified predicate is not defined.
IllegalArgumentException - if the difference of the base predicate and the specified predicate is not defined.
NullPointerException - if p is null.

compute

protected Object compute(BinaryFunction operator,
                         GeneralPredicate p)
Description copied from class: GeneralPredicateProxy
Placeholder for common implementation of all binary operations. (Binary operations are GeneralPredicateProxy.implies(net.sf.molae.logic.basic.GeneralPredicate, net.sf.molae.logic.basic.GeneralPredicate), GeneralPredicateProxy.and(net.sf.molae.logic.basic.GeneralPredicate), GeneralPredicateProxy.andNot(net.sf.molae.logic.basic.GeneralPredicate), GeneralPredicateProxy.or(net.sf.molae.logic.basic.GeneralPredicate) and GeneralPredicateProxy.xor(net.sf.molae.logic.basic.GeneralPredicate).)
Overrides:
compute in class GeneralPredicateProxy
Following copied from class: net.sf.molae.logic.basic.GeneralPredicateProxy
Parameters:
operator - the operation to perform
p - predicate to be conjoined with this predicate
Returns:
the result of the computation
Throws:
ClassCastException - if the result of the operation is not defined.
IllegalArgumentException - if the result of the operation is not defined.
NullPointerException - if p is null.