X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FRange.java;fp=src%2Fjalview%2Fdatamodel%2FRange.java;h=8b6f61702671cdd94d9bb8cf7a4eb4ce329848d3;hb=5143fe21d91fa16c40be42cc0923be0d6f2f6536;hp=0000000000000000000000000000000000000000;hpb=48eba1af1959565659fae9f9e7f4e28d9726c28c;p=jalview.git diff --git a/src/jalview/datamodel/Range.java b/src/jalview/datamodel/Range.java new file mode 100644 index 0000000..8b6f617 --- /dev/null +++ b/src/jalview/datamodel/Range.java @@ -0,0 +1,72 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.datamodel; + +/** + * An immutable data bean that models a start-end range + */ +public class Range implements ContiguousI +{ + public final int start; + + public final int end; + + @Override + public int getBegin() + { + return start; + } + + @Override + public int getEnd() + { + return end; + } + + public Range(int i, int j) + { + start = i; + end = j; + } + + @Override + public String toString() + { + return String.valueOf(start) + "-" + String.valueOf(end); + } + + @Override + public int hashCode() + { + return start * 31 + end; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof Range) + { + Range r = (Range) obj; + return (start == r.start && end == r.end); + } + return false; + } +}