wugle.expression
Interface Associative

All Superinterfaces:
BinaryOperator, java.lang.Cloneable, Expression, Operator
All Known Implementing Classes:
LogicBinaryOperator

public interface Associative
extends BinaryOperator

BinaryOperator that can perform the Associative Laws.

Any BinaryOperator that can perform the Associative Laws should implement this interface. The actual implementation can be delegated to an ExpressionOperation.

Version:
0.1.3
Author:
Jacob Perkins
See Also:
ExpressionOperation

Method Summary
 Associative associateLeft()
          Tries to perform the Associative Law to the right.
 Associative associateRight()
          Tries to perform the Associative Law to the right.
 boolean canAssociateLeft()
          Tests if can perform the Associative Law to the left.
 boolean canAssociateRight()
          Tests if can perform the Associative Law to the right.
 
Methods inherited from interface wugle.expression.BinaryOperator
getLeftChild, getRightChild, setLeftChild, setRightChild
 
Methods inherited from interface wugle.expression.Operator
setChild
 
Methods inherited from interface wugle.expression.Expression
clone, getParent, getSymbol, isEqual, setParent
 

Method Detail

canAssociateLeft

public boolean canAssociateLeft()
Tests if can perform the Associative Law to the left.

Returns:
true if the left child is the same class as this
See Also:
associateLeft(), ExpressionOperation.canAssociateLeft(Associative)

associateLeft

public Associative associateLeft()
                          throws java.lang.Exception
Tries to perform the Associative Law to the right. This will transform (p v q) v r to p v (q v r), which is the inverse of the associate right operation.

Returns:
The transformed expression
Throws:
java.lang.Exception - if the operation cannot be performed
See Also:
associateRight(), canAssociateLeft(), ExpressionOperation.associateLeft(Associative)

canAssociateRight

public boolean canAssociateRight()
Tests if can perform the Associative Law to the right.

Returns:
true if the right child is the same class as this
See Also:
associateRight(), ExpressionOperation.canAssociateRight(Associative)

associateRight

public Associative associateRight()
                           throws java.lang.Exception
Tries to perform the Associative Law to the right. This will transform p v (q v r) to (p v q) v r, which is the inverse of the associate left operation.

Returns:
The transformed expression
Throws:
java.lang.Exception - if the operation cannot be performed
See Also:
associateLeft(), canAssociateRight(), ExpressionOperation.associateRight(Associative)