Package com.ezylang.evalex.operators
Class AbstractOperator
- java.lang.Object
-
- com.ezylang.evalex.operators.AbstractOperator
-
- All Implemented Interfaces:
OperatorIfc
- Direct Known Subclasses:
InfixAndOperator,InfixDivisionOperator,InfixEqualsOperator,InfixGreaterEqualsOperator,InfixGreaterOperator,InfixLessEqualsOperator,InfixLessOperator,InfixMinusOperator,InfixModuloOperator,InfixMultiplicationOperator,InfixNotEqualsOperator,InfixOrOperator,InfixPlusOperator,InfixPowerOfOperator,PrefixMinusOperator,PrefixNotOperator,PrefixPlusOperator
public abstract class AbstractOperator extends java.lang.Object implements OperatorIfc
Abstract implementation of theOperatorIfc, used as base class for operator implementations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.ezylang.evalex.operators.OperatorIfc
OperatorIfc.OperatorType
-
-
Field Summary
-
Fields inherited from interface com.ezylang.evalex.operators.OperatorIfc
OPERATOR_PRECEDENCE_ADDITIVE, OPERATOR_PRECEDENCE_AND, OPERATOR_PRECEDENCE_COMPARISON, OPERATOR_PRECEDENCE_EQUALITY, OPERATOR_PRECEDENCE_MULTIPLICATIVE, OPERATOR_PRECEDENCE_OR, OPERATOR_PRECEDENCE_POWER, OPERATOR_PRECEDENCE_POWER_HIGHER, OPERATOR_PRECEDENCE_UNARY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOperator()Creates a new operator and uses theInfixOperatorannotation to create the operator definition.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetPrecedence(ExpressionConfiguration configuration)Called during parsing, can be implemented to return a customized precedence.booleanisInfix()If it is an infix operator.booleanisLeftAssociative()If operators with same precedence are evaluated from left to right.booleanisOperandLazy()Checks if the operand is lazy.booleanisPostfix()If it is a postfix operator.booleanisPrefix()If it is a prefix operator.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ezylang.evalex.operators.OperatorIfc
evaluate, getPrecedence
-
-
-
-
Constructor Detail
-
AbstractOperator
protected AbstractOperator()
Creates a new operator and uses theInfixOperatorannotation to create the operator definition.
-
-
Method Detail
-
getPrecedence
public int getPrecedence(ExpressionConfiguration configuration)
Description copied from interface:OperatorIfcCalled during parsing, can be implemented to return a customized precedence.- Specified by:
getPrecedencein interfaceOperatorIfc- Parameters:
configuration- The expression configuration.- Returns:
- The default precedence from the operator annotation, or a customized value.
-
isLeftAssociative
public boolean isLeftAssociative()
Description copied from interface:OperatorIfcIf operators with same precedence are evaluated from left to right.- Specified by:
isLeftAssociativein interfaceOperatorIfc- Returns:
- The associativity.
-
isOperandLazy
public boolean isOperandLazy()
Description copied from interface:OperatorIfcChecks if the operand is lazy.- Specified by:
isOperandLazyin interfaceOperatorIfc- Returns:
trueif operands are defined as lazy.
-
isPrefix
public boolean isPrefix()
Description copied from interface:OperatorIfcIf it is a prefix operator.- Specified by:
isPrefixin interfaceOperatorIfc- Returns:
trueif it is a prefix operator.
-
isPostfix
public boolean isPostfix()
Description copied from interface:OperatorIfcIf it is a postfix operator.- Specified by:
isPostfixin interfaceOperatorIfc- Returns:
trueif it is a postfix operator.
-
isInfix
public boolean isInfix()
Description copied from interface:OperatorIfcIf it is an infix operator.- Specified by:
isInfixin interfaceOperatorIfc- Returns:
trueif it is an infix operator.
-
-