@sap/odata-v4
Version:
OData V4.0 server library
86 lines (73 loc) • 2.26 kB
JavaScript
'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#_Toc453752661">
* OData CSDL # 14.5.15 Expression edm:UrlRef
* </a>
*
* @extends EdmAnnotationExpression
* @hideconstructor
*/
class EdmUrlRefExpression extends EdmAnnotationExpression {
/**
* @param {Edm} edm
* @param {CsdlUrlRefExpression} urlRef
*/
constructor(edm, urlRef) {
if (!edm) {
throw IllegalArgumentError.createForIllegalInstance('edm', 'Edm');
}
if (!urlRef) {
throw IllegalArgumentError.createForIllegalInstance('urlRef', 'CsdlUrlRefExpression');
}
super(CsdlAnnotationExpression.kinds.UrlRef);
/**
* @type {Edm}
* @private
*/
this._edm = edm;
/**
* @type {CsdlUrlRefExpression}
* @private
*/
this._urlRef = urlRef;
/**
* @type {EdmAnnotationExpression}
* @private
*/
this._expression = AnnotationFactory.createEdmExpressionFromCsdlExpression(edm, urlRef.expression);
/**
* @type {EdmAnnotation[]}
* @private
*/
this._annotations = null;
}
/**
* Returns the constant expression describing the url
*
* @returns {EdmAnnotationExpression}
*/
getExpression() {
return this._expression;
}
/**
* Returns the annotations for this object
*
* @returns {EdmAnnotation[]}
*/
getAnnotations() {
if (this._annotations) {
return this._annotations;
}
this._annotations = [];
for (let item of this._urlRef.annotations) {
this._annotations.push(AnnotationFactory.createAnnotation(this._edm, item));
}
return this._annotations;
}
}
module.exports = EdmUrlRefExpression;