package org.kne.cloud.network.monitor;

import org.kne.math.Long128;

public  class TimestampMonitorValue implements Comparable<TimestampMonitorValue> {
        private final Long128 timestamp;
        private final int count;
        private final int length;
        private final TimestampMonitorKey<?> key;
        private long delay;
        public TimestampMonitorValue(TimestampMonitorKey<?> key, Long128 timestamp,int count, int length) {
        	this(key,timestamp,count,length,Long.MAX_VALUE/1024);
        }
        public TimestampMonitorValue(TimestampMonitorKey<?> key, Long128 timestamp,int count, int length,long delay) {
            this.key = key;
            this.timestamp = timestamp;
            this.count=count;
            this.length = length;
            this.delay=delay;
        }
        
        @Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + (int) (delay ^ (delay >>> 32));
			result = prime * result + length;
			result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
			return result;
		}

        @Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			TimestampMonitorValue other = (TimestampMonitorValue) obj;
			if (delay != other.delay)
				return false;
			if (length != other.length)
				return false;
			if (timestamp == null) {
				if (other.timestamp != null)
					return false;
			} else if (!timestamp.equals(other.timestamp))
				return false;
			return true;
		}

        @Override
		public String toString() {
			return "TimestampMonitorValue [timestamp=" + timestamp + ", length=" + length + ", key=" + key + ", delay="
					+ delay + "]";
		}

        public Long128 getTimestamp() { return timestamp; }
        
        public int getCount() {
			return count;
		}
		public int getLength() { return length; }
        public TimestampMonitorKey<?> getKey() { return key; }
        
        
        public long getDelay() {
			return delay;
		}

		public void setDelay(long delay) {
			this.delay = delay;
		}

		@Override
        public int compareTo(TimestampMonitorValue other) {
            return this.timestamp.compareTo(other.timestamp);
        }
    }
    