package compbio.data.sequence; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; import java.util.Map; import compbio.util.annotation.NotThreadSafe; /** * TODO complete * * @author pvtroshin * * @param * enum type */ @NotThreadSafe // @XmlAccessorType(XmlAccessType.FIELD) public class MultiAnnotatedSequence> { private EnumMap> annotations; MultiAnnotatedSequence() { // default constructor for JAXB } public MultiAnnotatedSequence(Class enumeration) { this.annotations = new EnumMap>(enumeration); } public void addAnnotation(T type, ArrayList annotation) { assert type != null : "Type is expected"; assert annotation != null : "Not empty value is expected!"; if (!annotations.isEmpty()) { assert annotations.values().iterator().next().size() == annotation .size() : "Annotations must contain the same number of elements!"; } this.annotations.put(type, annotation); } public Map> getAnnotations() { return new EnumMap>(this.annotations); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((annotations == null) ? 0 : annotations.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; MultiAnnotatedSequence other = (MultiAnnotatedSequence) obj; if (annotations == null) { if (other.annotations != null) return false; } else if (!annotations.equals(other.annotations)) return false; return true; } @Override public String toString() { String value = ""; for (Map.Entry> annt : annotations.entrySet()) { value += annt.getKey() + " "; value += annt.getValue() + "\n"; } return value; } }