From: gmungoc Date: Wed, 13 Dec 2017 16:54:31 +0000 (+0000) Subject: JAL-2843 add isByAttribute to interface for convenience X-Git-Tag: Release_2_11_0~83 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7810a4a86cf5c344971dc1c834ac2227192badc2;p=jalview.git JAL-2843 add isByAttribute to interface for convenience --- diff --git a/src/jalview/datamodel/features/FeatureMatcher.java b/src/jalview/datamodel/features/FeatureMatcher.java index 50dd102..f844141 100644 --- a/src/jalview/datamodel/features/FeatureMatcher.java +++ b/src/jalview/datamodel/features/FeatureMatcher.java @@ -356,6 +356,12 @@ public class FeatureMatcher implements FeatureMatcherI return byScore; } + @Override + public boolean isByAttribute() + { + return getAttribute() != null; + } + /** * {@inheritDoc} The output of this method should be parseable by method * fromString to restore the original object. diff --git a/src/jalview/datamodel/features/FeatureMatcherI.java b/src/jalview/datamodel/features/FeatureMatcherI.java index 396f500..fa66468 100644 --- a/src/jalview/datamodel/features/FeatureMatcherI.java +++ b/src/jalview/datamodel/features/FeatureMatcherI.java @@ -43,6 +43,13 @@ public interface FeatureMatcherI boolean isByScore(); /** + * Answers true if match is against a feature attribute (text or range) + * + * @return + */ + boolean isByAttribute(); + + /** * Answers the match condition that is applied * * @return diff --git a/test/jalview/datamodel/features/FeatureMatcherTest.java b/test/jalview/datamodel/features/FeatureMatcherTest.java index fbbdbd5..4bd34cb 100644 --- a/test/jalview/datamodel/features/FeatureMatcherTest.java +++ b/test/jalview/datamodel/features/FeatureMatcherTest.java @@ -187,6 +187,16 @@ public class FeatureMatcherTest } @Test(groups = "Functional") + public void testIsByAttribute() + { + assertFalse(FeatureMatcher.byLabel(Condition.NotContains, "foo") + .isByAttribute()); + assertFalse(FeatureMatcher.byScore(Condition.LE, "-1").isByAttribute()); + assertTrue(FeatureMatcher.byAttribute(Condition.LE, "-1", "AC") + .isByAttribute()); + } + + @Test(groups = "Functional") public void testIsByLabel() { assertTrue(FeatureMatcher.byLabel(Condition.NotContains, "foo")