﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VAM_App.Model.Block
{
    public class BlockId : IEquatable<BlockId>, IComparable, IComparable<BlockId>
    {
        public BlockId(int value) {
            this.Value = value;
        }

        public int Value { get; private set; }

        public int CompareTo(BlockId other) {
            if (other == null) {
                return 1;
            }
            else if (this.Value == other.Value) {
                return 0;
            }
            else if (this.Value < other.Value) {
                return -1;
            }
            else {
                return 1;
            }
        }

        public int CompareTo(object obj) {
            if (obj == null) {
                return 1;
            }

            BlockId other = obj as BlockId;
            if (other != null) {
                return this.CompareTo(other);
            }
            else {
                throw new ArgumentException("Object is not a BlockId");
            }
        }

        public bool Equals(BlockId other) {
            return this.Value.Equals(other.Value);
        }

        public override bool Equals(object obj) {
            if (obj == null) {
                return false;
            }

            BlockId other = obj as BlockId;
            if (other != null) {
                return this.Equals(other);
            }
            else {
                return false;
            }
        }

        public override int GetHashCode() {
            return this.Value.GetHashCode();
        }

    }
}
