"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/**
 * Match for a Map
 *
 * Match contains the instance of the Task and a
 * percentage from 0 to 1. In cases of overlapping
 * of Matches the one with bigger percentage will be
 * used
 *
 * @param {Task} instance any Task instance
 * @param {number} percentage from 0 to 1
 */
var Match = function () {
  /**
   * Match constructor
   *
   * @param {Task} instance any Task instance
   * @param {number} percentage from 0 to 1
   */
  function Match(instance, percentage) {
    _classCallCheck(this, Match);

    this._percentage = 0.5;
    this.instance = instance;

    this.percentage = percentage;
  }

  /**
   * Percentage setter
   *
   * @param {number} value from 0 to 1
   */


  _createClass(Match, [{
    key: "percentage",
    set: function set(value) {
      if (value !== undefined && value !== null && value !== false) {
        this._percentage = value > 1 ? 1 : value < 0 ? 0 : value;
      }
    }

    /**
     * Percentage getter
     *
     * @return {number} percentage value from 0 to 1
     */
    ,
    get: function get() {
      return this._percentage;
    }
  }]);

  return Match;
}();

exports.default = Match;