using System;

namespace LemmaSharp
{
    [Serializable]
    class RuleWeighted : IComparable<RuleWeighted>
    {
        #region Private Variables
        private LemmaRule lrRule;
        private double dWeight;
        #endregion

        #region Constructor(s)
        public RuleWeighted(LemmaRule lrRule, double dWeight)
        {
            this.lrRule = lrRule;
            this.dWeight = dWeight;
        }
        #endregion

        #region Public Properties
        public LemmaRule Rule
        {
            get { return lrRule; }
        }
        public double Weight
        {
            get { return dWeight; }
        }
        #endregion

        #region Essential Class Functions (comparing objects, eg.: for sorting)
        public int CompareTo(RuleWeighted rl)
        {
            if (this.dWeight < rl.dWeight) return 1;
            if (this.dWeight > rl.dWeight) return -1;
            if (this.lrRule.Id < rl.lrRule.Id) return 1;
            if (this.lrRule.Id > rl.lrRule.Id) return -1;
            return 0;
        }
        #endregion

        #region Output & Serialization Functions
        public override string ToString()
        {
            return string.Format("{0}{1:(0.00%)}", lrRule, dWeight);
        }
        #endregion
    }
}
