package org.onlab.onos.store.device.impl;

import org.onlab.onos.store.Timestamp;

/**
 * Wrapper class for a entity that is versioned
 * and can either be up or down.
 *
 * @param <T> type of the value.
 */
public class VersionedValue<T> {
    private final T entity;
    private final Timestamp timestamp;
    private final boolean isUp;

    public VersionedValue(T entity, boolean isUp, Timestamp timestamp) {
        this.entity = entity;
        this.isUp = isUp;
        this.timestamp = timestamp;
    }

    /**
     * Returns the value.
     * @return value.
     */
    public T entity() {
        return entity;
    }

    /**
     * Tells whether the entity is up or down.
     * @return true if up, false otherwise.
     */
    public boolean isUp() {
        return isUp;
    }

    /**
     * Returns the timestamp (version) associated with this entity.
     * @return timestamp.
     */
    public Timestamp timestamp() {
        return timestamp;
    }


    // Default constructor for serializer
    protected VersionedValue() {
        this.entity = null;
        this.isUp = false;
        this.timestamp = null;
    }
}

@@ -36,16 +36,43 @@
 .impl;%0A%0A
+import java.util.Objects;%0A%0A
 import o
@@ -993,16 +993,661 @@
     %7D%0A%0A%0A
+    @Override%0A    public int hashCode() %7B%0A        return Objects.hash(entity, timestamp, isUp);%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (this == obj) %7B%0A            return true;%0A        %7D%0A        if (obj == null) %7B%0A            return false;%0A        %7D%0A        if (getClass() != obj.getClass()) %7B%0A            return false;%0A        %7D%0A        @SuppressWarnings(%22unchecked%22)%0A        VersionedValue%3CT%3E that = (VersionedValue%3CT%3E) obj;%0A        return Objects.equals(this.entity, that.entity) &&%0A                Objects.equals(this.timestamp, that.timestamp) &&%0A                Objects.equals(this.isUp, that.isUp);%0A    %7D%0A%0A
     // D

add equals, hashCode to VersionedValue