
at.molindo.scrutineer.AbstractIdAndVersion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scrutineer Show documentation
Show all versions of scrutineer Show documentation
Compares 2 streams of Ids and Versions to prove that a secondary source is
in sync with a primary source of truth. Designed to verify an elasticsearch
cluster contains correct information from a JDBC source.
The newest version!
package at.molindo.scrutineer;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
public abstract class AbstractIdAndVersion implements IdAndVersion {
private final long version;
protected AbstractIdAndVersion(final long version) {
this.version = version;
}
@Override
public long getVersion() {
return version;
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof AbstractIdAndVersion)) {
return false;
}
final AbstractIdAndVersion other = (AbstractIdAndVersion) obj;
return compareTo(other) == 0;
}
@Override
public int hashCode() {
return appendId(new HashCodeBuilder()).append(version).toHashCode();
}
@Override
public String toString() {
return getId() + ":" + getVersion();
}
@Override
public int compareTo(final IdAndVersion other) {
return appendId(new CompareToBuilder(), other).append(version, other.getVersion()).toComparison();
}
protected abstract HashCodeBuilder appendId(HashCodeBuilder appender);
protected abstract CompareToBuilder appendId(CompareToBuilder appender, IdAndVersion other);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy