All Downloads are FREE. Search and download functionalities are using the official Maven repository.

brooklyn.util.collections.TimestampedValue Maven / Gradle / Ivy

Go to download

Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else

There is a newer version: 0.7.0-M1
Show newest version
package brooklyn.util.collections;

import com.google.common.base.Objects;

public class TimestampedValue {

    private final T value;
    private final long timestamp;
    
    public TimestampedValue(T value, long timestamp) {
        this.value = value;
        this.timestamp = timestamp;
    }
    
    public T getValue() {
        return value;
    }
    
    public long getTimestamp() {
        return timestamp;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(value, timestamp);
    }
    
    @Override
    public boolean equals(Object other) {
        if (!(other instanceof TimestampedValue)) {
            return false;
        }
        TimestampedValue o = (TimestampedValue) other;
        return o.getTimestamp() == timestamp && Objects.equal(o.getValue(), value);
    }
    
    @Override
    public String toString() {
        return "val="+value+"; timestamp="+timestamp;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy