From 7810a4a86cf5c344971dc1c834ac2227192badc2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 13 Dec 2017 16:54:31 +0000 Subject: [PATCH] JAL-2843 add isByAttribute to interface for convenience --- src/jalview/datamodel/features/FeatureMatcher.java | 6 ++++++ src/jalview/datamodel/features/FeatureMatcherI.java | 7 +++++++ test/jalview/datamodel/features/FeatureMatcherTest.java | 10 ++++++++++ 3 files changed, 23 insertions(+) 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") -- 1.7.10.2