public class Expression extends Object
Expressions may be used to build Filter
instances. An expression consists of a left and a right Operand
, operated on by a BinaryRelationalOperator
.
An Expression
instance overrides Expression.hashCode()
and Expression.equals(Object)
and hence can be used in sets.
Constructor and Description |
---|
Expression()
Default constructor does not instantiate any fields.
|
Expression(Expression source)
Copy constructor builds a new instance from the source.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares the specified object with this expression for equality.
|
Operand.LeftOperand<String> |
getLeft()
Returns the left operand of this expression.
|
BinaryRelationalOperator |
getRelationalOperator()
Returns the binary relational operator set in this expression.
|
Operand.RightOperand<String> |
getRight()
Returns the right operand for this expression.
|
int |
hashCode()
Returns the hash code value for this expression.
|
boolean |
isComplement()
Returns
true if the binary relational operation in this expression is to be complemented. |
void |
setComplement(boolean complement)
Set to
true if the binary relational operation in this expression is to be complemented. |
void |
setLeft(Operand.LeftOperand<String> left)
Sets the left operand for this expression.
|
void |
setRelationalOperator(BinaryRelationalOperator relationalOperator)
Sets the binary relational operator in this expression.
|
void |
setRight(Operand.RightOperand<String> right)
Sets the right operand for this expression.
|
String |
toString()
Returns a string representation of this expression.
|
public Expression()
public Expression(Expression source)
source
- the source instance from which the state is replicated in the new instance.public Operand.LeftOperand<String> getLeft()
public void setLeft(Operand.LeftOperand<String> left)
left
- the left operand of the expression to setpublic Operand.RightOperand<String> getRight()
public void setRight(Operand.RightOperand<String> right)
right
- the right operand of the expression to setpublic boolean isComplement()
true
if the binary relational operation in this expression is to be complemented.true
if the binary relational operation in this expression is to be complemented, false
otherwise.public void setComplement(boolean complement)
true
if the binary relational operation in this expression is to be complemented.complement
- set to true
if the binary relational operation in this expression is to be complemented, false
otherwise.public BinaryRelationalOperator getRelationalOperator()
public void setRelationalOperator(BinaryRelationalOperator relationalOperator)
relationalOperator
- the relational operator to setpublic String toString()
The string representation is: Left-Value Binary-Relational-Operator Right-Value
toString
in class Object
Object.toString()
public int hashCode()
The hash code of an expression is defined to be the sum of the hash codes of its relational operator and its relational operands. This ensures that e1.equals(e2)
implies that e1.hashCode() == e2.hashCode()
for any two expressions e1
and e2
, as required by the general contract of Object.hashCode()
.
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
Returns true
if the given object is also an expression and the two expressions represent the same relational operation. Two expressions e1
and e2
represent the same relational operation if e1.getLeft().equals(e2.getLeft())
, e1.getRight().equals(e2.getRight())
, e1.getRelationalOperator().equals(e2.getRelationalOperator())
.
This implementation first checks if the specified object is this expression; if so it returns true
. Then, it checks if the specified object is an expression whose binary operation (the left and right operands, and the binary relational operator are also equal).
equals
in class Object
obj
- object to be compared for equality with this expressiontrue
if the specified object is equal to this expressionObject.equals(java.lang.Object)