X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=datamodel%2Fcompbio%2Fdata%2Fsequence%2FAnnotatedSequence.java;h=65dbce96f5f0f8bbb2245034c6a148967c8aaf82;hb=0c69f6b897b652489cdf0e740bb01cef51cc60c1;hp=5d09534a375a94315f4496227400a86072581c7a;hpb=48190e32e896a6f674284844a9ae75605aa40157;p=jabaws.git diff --git a/datamodel/compbio/data/sequence/AnnotatedSequence.java b/datamodel/compbio/data/sequence/AnnotatedSequence.java index 5d09534..65dbce9 100644 --- a/datamodel/compbio/data/sequence/AnnotatedSequence.java +++ b/datamodel/compbio/data/sequence/AnnotatedSequence.java @@ -4,53 +4,58 @@ import java.util.Arrays; public class AnnotatedSequence extends FastaSequence { - private final float[] annotation; - - public AnnotatedSequence(String id, String sequence, float[] annotation) { - super(id, sequence); - this.annotation = annotation; - if (annotation == null || annotation.length != sequence.length()) { - throw new IllegalArgumentException("The length of the annotation (" - + ((annotation != null) ? annotation.length : "0") - + ") does not match the length of the sequence (" - + sequence.length() + ")!"); + private float[] annotation; + + private AnnotatedSequence() { + super(); + // JAXB default constructor + } + + public AnnotatedSequence(String id, String sequence, float[] annotation) { + super(id, sequence); + this.annotation = annotation; + if (annotation == null || annotation.length != sequence.length()) { + throw new IllegalArgumentException("The length of the annotation (" + + ((annotation != null) ? annotation.length : "0") + + ") does not match the length of the sequence (" + + sequence.length() + ")!"); + } + } + + public AnnotatedSequence(FastaSequence fsequence, float[] annotation) { + this(fsequence.getId(), fsequence.getSequence(), annotation); + } + + public float[] getAnnotation() { + return annotation; + } + + @Override + public int hashCode() { + final int prime = 7; + int result = super.hashCode(); + result = prime * result + Arrays.hashCode(annotation); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + AnnotatedSequence other = (AnnotatedSequence) obj; + if (!Arrays.equals(annotation, other.annotation)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + "Annotation:\n " + + Arrays.toString(annotation) + "\n"; } - } - - public AnnotatedSequence(FastaSequence fsequence, float[] annotation) { - this(fsequence.getId(), fsequence.getSequence(), annotation); - } - - public float[] getAnnotation() { - return annotation; - } - - @Override - public int hashCode() { - final int prime = 7; - int result = super.hashCode(); - result = prime * result + Arrays.hashCode(annotation); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - AnnotatedSequence other = (AnnotatedSequence) obj; - if (!Arrays.equals(annotation, other.annotation)) - return false; - return true; - } - - @Override - public String toString() { - return super.toString() + "Annotation:\n " - + Arrays.toString(annotation) + "\n"; - } }