UNPKG

@sap/odata-v4

Version:

OData V4.0 server library

86 lines (72 loc) 2.31 kB
'use strict'; const AnnotationFactory = require('./AnnotationExpressionFactory'); const CsdlAnnotationExpression = require('../../csdl/annotationExpression/CsdlAnnotationExpression'); const EdmAnnotationExpression = require('./EdmAnnotationExpression'); const IllegalArgumentError = require('../../errors/IllegalArgumentError'); /** * * <a href="./../ODataSpecification/odata-v4.0-errata03-os/complete/part3-csdl/odata-v4.0-errata03-os-part3-csdl-complete.html#_Toc453752660"> * OData CSDL # 14.5.14.2 Element edm:PropertyValue * </a> * * @extends EdmAnnotationExpression * @hideconstructor */ class EdmPropertyValueExpression extends EdmAnnotationExpression { /** * @param {Edm} edm * @param {CsdlPropertyValueExpression} expression */ constructor(edm, expression) { if (!edm) { throw IllegalArgumentError.createForIllegalInstance('edm', 'Edm'); } if (!expression) { throw IllegalArgumentError.createForIllegalInstance('expression', 'CsdlPropertyValueExpression'); } super(CsdlAnnotationExpression.kinds.PropertyValue); this._edm = edm; this._expression = expression; /** * @type {EdmAnnotationExpression} * @private */ this._edmExpression = AnnotationFactory.createEdmExpressionFromCsdlExpression(edm, this._expression.expression); /** * @type {EdmAnnotation[]} * @private */ this._annotations = null; } /** * Returns the property name * * @returns {string} */ getProperty() { return this._expression.property; } /** * Returns the property value * @returns {EdmAnnotationExpression} */ getExpression() { return this._edmExpression; } /** * Returns the annotations for this object * * @returns {EdmAnnotation[]} */ getAnnotations() { if (this._annotations) { return this._annotations; } this._annotations = []; for (let item of this._expression.annotations) { this._annotations.push(AnnotationFactory.createAnnotation(this._edm, item)); } return this._annotations; } } module.exports = EdmPropertyValueExpression;