UNPKG

@sap/odata-v4

Version:

OData V4.0 server library

127 lines (104 loc) 2.61 kB
'use strict'; const Expression = require('./Expression'); /** * Binary expression, consisting of left and right operands and an operator. * * @extends Expression * @hideconstructor */ class BinaryExpression extends Expression { /** * Create an instance of BinaryExpression. * @param {Expression} left left part * @param {BinaryExpression.OperatorKind} operator operator * @param {Expression} right right part * @param {?EdmType} type EDM type of this expression or null if there is none */ constructor(left, operator, right, type) { super(Expression.ExpressionKind.BINARY); /** * @type {Expression} * @private */ this._left = left; /** * @type {BinaryExpression.OperatorKind} * @private */ this._operator = operator; /** * @type {Expression} * @private */ this._right = right; /** * @type {EdmType} * @private */ this._type = type; } /** * Return the left operand. * @returns {Expression} the left operand */ getLeftOperand() { return this._left; } /** * Return the operator. * @returns {BinaryExpression.OperatorKind} the operator */ getOperator() { return this._operator; } /** * Return the right operand. * @returns {Expression} the right operand */ getRightOperand() { return this._right; } /** * Return the EDM type of this expression or null if there is none. * @returns {?EdmType} the EDM type of this expression or null if there is none */ getType() { return this._type; } } /** * Defined binary operators. * @enum {string} * @readonly */ BinaryExpression.OperatorKind = { /** OData has operator used for OData enumerations */ HAS: 'has', /** Multiplication operator */ MUL: 'mul', /** Division operator */ DIV: 'div', /** Modulo operator */ MOD: 'mod', /** Addition operator */ ADD: 'add', /** Subtraction operator */ SUB: 'sub', /** Greater than operator : '>' */ GT: 'gt', /** Greater than or equals operator : '>=' */ GE: 'ge', /** Less than operator : '<' */ LT: 'lt', /** Less than or equals operator : '<=' */ LE: 'le', /** Equality operator */ EQ: 'eq', /** Inequality operator */ NE: 'ne', /** And operator */ AND: 'and', /** Or operator */ OR: 'or' }; module.exports = BinaryExpression;