@sap/odata-v4
Version:
OData V4.0 server library
45 lines (38 loc) • 1.39 kB
JavaScript
;
const Expression = require('./Expression');
/**
* @extends Expression
* @hideconstructor
*/
class LiteralExpression extends Expression {
/**
* Create an instance of LiteralExpression.
* @param {?string} text the literal value or null if a literal null has been given
* @param {?EdmType} type EDM type of this literal or null if there is none
*/
constructor(text, type) {
super(Expression.ExpressionKind.LITERAL);
this._text = text;
this._type = type;
}
/**
* Return the literal value. This is a string or null if a literal null has been given.
* @returns {?string} the literal value
*/
getText() {
return this._text;
}
/**
* Return the EDM type of this expression or null if there is none.
* Numeric literals without a dot and without an e return the smallest possible Edm Integer type.
* Numeric literals without a dot, without an e, and larger than 2^63 - 1 are considered to be Edm.Decimal.
* Numeric literals with an e are considered to be Edm.Double.
* Numeric literals with a dot and without an e are supposed to be Edm.Decimal.
*
* @returns {?EdmType} Type of the literal if detected. The type of the literal is guessed by the parser.
*/
getType() {
return this._type;
}
}
module.exports = LiteralExpression;