All files / lib/model/nw/schema AssociationEnd.js

100% Statements 9/9
100% Branches 0/0
100% Functions 6/6
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                  21x 1x     21x 1x     21x 18x                       15x 1x         1x  
"use strict";
 
/**
 * Envelops an association end.
 *
 * https://docs.microsoft.com/en-us/openspecs/windows_protocols/mc-csdl/f5fec50d-2930-4265-945d-965cd4db8153
 * (not present in OASIS-CSDL)
 *
 * @class AssociationEnd
 */
class AssociationEnd {
  /**
   * Creates an instance of AssociationEnd.
   * @param {Object} rawMetadata raw metadata object for the association end
   * @memberof AssociationEnd
   */
  constructor(rawMetadata) {
    Object.defineProperty(this, "raw", {
      get: () => rawMetadata,
    });
 
    Object.defineProperty(this, "multiplicity", {
      get: () => rawMetadata.$.Multiplicity,
    });
 
    Object.defineProperty(this, "role", {
      get: () => rawMetadata.$.Role,
    });
  }
 
  /**
   * Initializes schema dependent properties. Decoupled from constructor,
   * because it needs to resolve schema (type) references.
   *
   * @param {CsdlSchema} schema to resolve references
   * @memberof AssociationEnd
   */
  initSchemaDependentProperties(schema) {
    Object.defineProperty(this, "type", {
      get: () => schema.getType(this.raw.$.Type),
    });
  }
}
 
module.exports = AssociationEnd;