com.regnosys.rosetta.translate.SynonymValueGroup Maven / Gradle / Ivy
package com.regnosys.rosetta.translate;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.regnosys.rosetta.common.translation.Path;
/**
* @author TomForwood
* This class represents a single synonym group inside the parse handlers
* e.g [synonym Bank_A, Bank_B value aField, bField path cField]
* has sources Bank_A and Bank_B
* and two paths {aField, cField.bField}
*/
public class SynonymValueGroup {
private final List paths;
public SynonymValueGroup(List paths) {
this.paths = paths;
}
public SynonymValueGroup(String... pathStrings) {
paths = Arrays.stream(pathStrings).map(s->Path.parse(s)).collect(Collectors.toList());
}
public List getPaths() {
return paths;
}
public boolean startMatches(Path path) {
return getPaths().stream().anyMatch(p->p.nameStartMatches(path));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((paths == null) ? 0 : paths.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;
SynonymValueGroup other = (SynonymValueGroup) obj;
if (paths == null) {
if (other.paths != null)
return false;
} else if (!paths.equals(other.paths))
return false;
return true;
}
@Override
public String toString() {
return "SynonymGroup [paths=" + paths + "]";
}
}