com.regnosys.rosetta.translate.synonymmap.SynonymValue Maven / Gradle / Ivy
package com.regnosys.rosetta.translate.synonymmap;
import java.util.List;
import java.util.stream.Collectors;
import com.regnosys.rosetta.translate.datamodel.Cardinality;
public class SynonymValue {
private final List synonymPath;
private final int mapsTo;
private final boolean isMeta;
public SynonymValue(List synonymPath, int mapsTo, boolean isMeta) {
this.synonymPath = synonymPath;
this.mapsTo = mapsTo;
this.isMeta = isMeta;
}
public List getSynonymPath() {
return synonymPath;
}
public int getMapsTo() {
return mapsTo;
}
public boolean isMeta() {
return isMeta;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (isMeta ? 1231 : 1237);
result = prime * result + mapsTo;
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;
SynonymValue other = (SynonymValue) obj;
if (isMeta != other.isMeta)
return false;
if (mapsTo != other.mapsTo)
return false;
if (synonymPath == null) {
if (other.synonymPath != null)
return false;
} else if (!synonymPath.equals(other.synonymPath))
return false;
return true;
}
@Override
public String toString() {
return "SynonymValue [synonymPath=" + synonymPath + ", mapsTo=" + mapsTo + ", isMeta=" + isMeta + "]";
}
String toPathString() {
return synonymPath.stream().map(e->e.getName()+(e.getCardinality()==Cardinality.MULTIPLE?"*":"")).collect(Collectors.joining(SynonymTest.PATH_SEPARATOR));
}
}