org.diirt.datasource.timecache.source.SourceData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datasource-timecache Show documentation
Show all versions of datasource-timecache Show documentation
Local cache for time series gathered from multiple sources.
The newest version!
/**
* Copyright (C) 2010-14 diirt developers. See COPYRIGHT.TXT
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
*/
package org.diirt.datasource.timecache.source;
import org.diirt.datasource.timecache.Data;
import org.diirt.util.time.Timestamp;
import org.diirt.vtype.VType;
/**
* {@link Data} from {@link DataSource}.
* @author Fred Arnaud (Sopra Group) - ITER
*/
public class SourceData implements Data {
private final Timestamp timestamp;
private final VType value;
public SourceData(Timestamp timestamp, VType value) {
this.timestamp = timestamp;
this.value = value;
}
/** {@inheritDoc} */
@Override
public Timestamp getTimestamp() {
return timestamp;
}
/** {@inheritDoc} */
@Override
public VType getValue() {
return value;
}
/** {@inheritDoc} */
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((timestamp == null) ? 0 : timestamp.hashCode());
return result;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SourceData other = (SourceData) obj;
if (timestamp == null) {
if (other.timestamp != null)
return false;
} else if (!timestamp.equals(other.timestamp))
return false;
return true;
}
/** {@inheritDoc} */
@Override
public int compareTo(Data d) {
return timestamp.compareTo(d.getTimestamp());
}
/** {@inheritDoc} */
@Override
public String toString() {
return "SourceData [timestamp=" + timestamp + ", value=" + value + "]";
}
}