JAL-2843 add isByAttribute to interface for convenience
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 13 Dec 2017 16:54:31 +0000 (16:54 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 13 Dec 2017 16:54:31 +0000 (16:54 +0000)
src/jalview/datamodel/features/FeatureMatcher.java
src/jalview/datamodel/features/FeatureMatcherI.java
test/jalview/datamodel/features/FeatureMatcherTest.java

index 50dd102..f844141 100644 (file)
@@ -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
    * <code>fromString<code> to restore the original object.
index 396f500..fa66468 100644 (file)
@@ -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
index fbbdbd5..4bd34cb 100644 (file)
@@ -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")