From: gmungoc Date: Fri, 26 May 2017 07:33:28 +0000 (+0100) Subject: JAL-2480 move ContiguousI and Range to jalview.datamodel X-Git-Tag: Release_2_10_3b1~229 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=807f5945ffa954c38f07cbf9d2a4ebc22cfe5eb9;p=jalview.git JAL-2480 move ContiguousI and Range to jalview.datamodel --- diff --git a/src/jalview/datamodel/features/ContiguousI.java b/src/jalview/datamodel/ContiguousI.java similarity index 75% rename from src/jalview/datamodel/features/ContiguousI.java rename to src/jalview/datamodel/ContiguousI.java index d0b3259..f2ae4b7 100644 --- a/src/jalview/datamodel/features/ContiguousI.java +++ b/src/jalview/datamodel/ContiguousI.java @@ -1,4 +1,4 @@ -package jalview.datamodel.features; +package jalview.datamodel; public interface ContiguousI { diff --git a/src/jalview/datamodel/Range.java b/src/jalview/datamodel/Range.java new file mode 100644 index 0000000..7886713 --- /dev/null +++ b/src/jalview/datamodel/Range.java @@ -0,0 +1,52 @@ +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; + } +} diff --git a/src/jalview/datamodel/features/FeatureLocationI.java b/src/jalview/datamodel/features/FeatureLocationI.java index d6f0389..e651c13 100644 --- a/src/jalview/datamodel/features/FeatureLocationI.java +++ b/src/jalview/datamodel/features/FeatureLocationI.java @@ -1,5 +1,7 @@ package jalview.datamodel.features; +import jalview.datamodel.ContiguousI; + /** * An extension of ContiguousI that allows start/end values to be interpreted * instead as two contact positions diff --git a/src/jalview/datamodel/features/FeatureStore.java b/src/jalview/datamodel/features/FeatureStore.java index 332e9ec..1b6277c 100644 --- a/src/jalview/datamodel/features/FeatureStore.java +++ b/src/jalview/datamodel/features/FeatureStore.java @@ -1,5 +1,6 @@ package jalview.datamodel.features; +import jalview.datamodel.ContiguousI; import jalview.datamodel.SequenceFeature; import java.util.ArrayList; diff --git a/src/jalview/datamodel/features/NCList.java b/src/jalview/datamodel/features/NCList.java index a911666..a6a23e7 100644 --- a/src/jalview/datamodel/features/NCList.java +++ b/src/jalview/datamodel/features/NCList.java @@ -1,5 +1,8 @@ package jalview.datamodel.features; +import jalview.datamodel.ContiguousI; +import jalview.datamodel.Range; + import java.util.ArrayList; import java.util.Collections; import java.util.List; diff --git a/src/jalview/datamodel/features/NCNode.java b/src/jalview/datamodel/features/NCNode.java index 38c091e..c1be242 100644 --- a/src/jalview/datamodel/features/NCNode.java +++ b/src/jalview/datamodel/features/NCNode.java @@ -1,5 +1,7 @@ package jalview.datamodel.features; +import jalview.datamodel.ContiguousI; + import java.util.ArrayList; import java.util.List; diff --git a/src/jalview/datamodel/features/Range.java b/src/jalview/datamodel/features/Range.java deleted file mode 100644 index beb2874..0000000 --- a/src/jalview/datamodel/features/Range.java +++ /dev/null @@ -1,33 +0,0 @@ -package jalview.datamodel.features; - - -public class Range implements ContiguousI -{ - final int start; - - 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); - } -} diff --git a/src/jalview/datamodel/features/RangeComparator.java b/src/jalview/datamodel/features/RangeComparator.java index 05d3f0a..26ffee1 100644 --- a/src/jalview/datamodel/features/RangeComparator.java +++ b/src/jalview/datamodel/features/RangeComparator.java @@ -1,5 +1,7 @@ package jalview.datamodel.features; +import jalview.datamodel.ContiguousI; + import java.util.Comparator; /** diff --git a/src/jalview/datamodel/features/SequenceFeatures.java b/src/jalview/datamodel/features/SequenceFeatures.java index 6955ade..8f6d496 100644 --- a/src/jalview/datamodel/features/SequenceFeatures.java +++ b/src/jalview/datamodel/features/SequenceFeatures.java @@ -1,5 +1,6 @@ package jalview.datamodel.features; +import jalview.datamodel.ContiguousI; import jalview.datamodel.SequenceFeature; import jalview.io.gff.SequenceOntologyFactory; import jalview.io.gff.SequenceOntologyI; diff --git a/test/jalview/datamodel/features/NCListTest.java b/test/jalview/datamodel/features/NCListTest.java index 3561a78..2c7f752 100644 --- a/test/jalview/datamodel/features/NCListTest.java +++ b/test/jalview/datamodel/features/NCListTest.java @@ -4,6 +4,8 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; +import jalview.datamodel.ContiguousI; +import jalview.datamodel.Range; import jalview.datamodel.SequenceFeature; import java.util.ArrayList; diff --git a/test/jalview/datamodel/features/NCNodeTest.java b/test/jalview/datamodel/features/NCNodeTest.java index ca227c5..4713084 100644 --- a/test/jalview/datamodel/features/NCNodeTest.java +++ b/test/jalview/datamodel/features/NCNodeTest.java @@ -4,6 +4,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import jalview.datamodel.Range; import jalview.datamodel.SequenceFeature; import java.util.ArrayList; diff --git a/test/jalview/datamodel/features/RangeComparatorTest.java b/test/jalview/datamodel/features/RangeComparatorTest.java index e58ce6a..4849b38 100644 --- a/test/jalview/datamodel/features/RangeComparatorTest.java +++ b/test/jalview/datamodel/features/RangeComparatorTest.java @@ -2,6 +2,9 @@ package jalview.datamodel.features; import static org.testng.Assert.assertEquals; +import jalview.datamodel.ContiguousI; +import jalview.datamodel.Range; + import java.util.Comparator; import org.testng.annotations.Test;