com.regnosys.rosetta.translate.SynonymAttributePath Maven / Gradle / Ivy
package com.regnosys.rosetta.translate;
import java.util.Comparator;
class SynonymAttributePath implements Comparable {
private final Comparator comparator =
Comparator.comparing(SynonymAttributePath::getSynonymPath)
.thenComparing(SynonymAttributePath::getAttributePath)
.thenComparing(SynonymAttributePath::getIndex);
private final String synonymPath;
private final String attributePath;
private final int index;
public SynonymAttributePath(String synonymPath, String attributePath, int index) {
this.synonymPath = synonymPath;
this.attributePath = attributePath;
this.index = index;
}
public String getSynonymPath() {
return synonymPath;
}
public String getAttributePath() {
return attributePath;
}
public int getIndex() {
return index;
}
@Override
public int compareTo(SynonymAttributePath other) {
return comparator.compare(this, other);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((attributePath == null) ? 0 : attributePath.hashCode());
result = prime * result + ((synonymPath == null) ? 0 : synonymPath.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;
SynonymAttributePath other = (SynonymAttributePath) obj;
if (attributePath == null) {
if (other.attributePath != null)
return false;
} else if (!attributePath.equals(other.attributePath))
return false;
if (synonymPath == null) {
if (other.synonymPath != null)
return false;
} else if (!synonymPath.equals(other.synonymPath))
return false;
return true;
}
}