text: "use strict";
  /**
   * Storage all metadatas of validations.
   */
  var MetadataStorage = (function () {
      function MetadataStorage() {
          // -------------------------------------------------------------------------
          // Properties
          // -------------------------------------------------------------------------
          this._validationMetadatas = [];
          this._constraintMetadatas = [];
      }
      Object.defineProperty(MetadataStorage.prototype, "validationMetadatas", {
          // -------------------------------------------------------------------------
          // Getter Methods
          // -------------------------------------------------------------------------
          /**
           * Gets all validation metadatas saved in this storage.
           */
          get: function () {
              return this._validationMetadatas;
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(MetadataStorage.prototype, "constraintMetadatas", {
          /**
           * Gets all constraint metadatas saved in this storage.
           */
          get: function () {
              return this._constraintMetadatas;
          },
          enumerable: true,
          configurable: true
      });
      // -------------------------------------------------------------------------
      // Adder Methods
      // -------------------------------------------------------------------------
      /**
       * Adds a new validation metadata.
       */
      MetadataStorage.prototype.addValidationMetadata = function (metadata) {
          this.validationMetadatas.push(metadata);
      };
      /**
       * Adds a new constraint metadata.
       */
      MetadataStorage.prototype.addConstraintMetadata = function (metadata) {
          this.constraintMetadatas.push(metadata);
      };
      // -------------------------------------------------------------------------
      // Public Methods
      // -------------------------------------------------------------------------
      /**
       * Gets all validation metadatas for the given object with the given groups.
       */
      MetadataStorage.prototype.getValidationMetadatasForObject = function (object, groups) {
          return this.validationMetadatas
              .filter(function (metadata) { return metadata.object.constructor === object; })
              .filter(function (metadata) { return groups && groups.length > 0 ? metadata.always || (metadata.groups && metadata.groups.filter(function (g) { return groups.indexOf(g) !== -1; }).length > 0) : true; });
      };
      /**
       * Gets all validator constraints for the given object.
       */
      MetadataStorage.prototype.getValidatorConstraintsForObject = function (object) {
          return this.constraintMetadatas.filter(function (metadata) { return metadata.object === object; });
      };
      return MetadataStorage;
  }());
  exports.MetadataStorage = MetadataStorage;
  /**
   * Default metadata storage used as singleton and can be used to storage all metadatas in the system.
   */
  exports.defaultMetadataStorage = new MetadataStorage();
  //# sourceMappingURL=MetadataStorage.js.map