JAL-2808 refactor KeyedMatcher as FeatureMatcher with byLabel, byScore, byAttribute...
[jalview.git] / src / jalview / datamodel / features / FeatureMatcherSet.java
@@ -1,25 +1,26 @@
-package jalview.util.matcher;
+package jalview.datamodel.features;
+
+import jalview.datamodel.SequenceFeature;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.function.Function;
 
-public class KeyedMatcherSet implements KeyedMatcherSetI
+public class FeatureMatcherSet implements FeatureMatcherSetI
 {
-  List<KeyedMatcherI> matchConditions;
+  List<FeatureMatcherI> matchConditions;
 
   boolean andConditions;
 
   /**
    * Constructor
    */
-  public KeyedMatcherSet()
+  public FeatureMatcherSet()
   {
     matchConditions = new ArrayList<>();
   }
 
   @Override
-  public boolean matches(Function<String[], String> valueProvider)
+  public boolean matches(SequenceFeature feature)
   {
     /*
      * no conditions matches anything
@@ -34,9 +35,9 @@ public class KeyedMatcherSet implements KeyedMatcherSetI
      */
     if (andConditions)
     {
-      for (KeyedMatcherI m : matchConditions)
+      for (FeatureMatcherI m : matchConditions)
       {
-        if (!m.matches(valueProvider))
+        if (!m.matches(feature))
         {
           return false;
         }
@@ -47,9 +48,9 @@ public class KeyedMatcherSet implements KeyedMatcherSetI
     /*
      * OR until match
      */
-    for (KeyedMatcherI m : matchConditions)
+    for (FeatureMatcherI m : matchConditions)
     {
-      if (m.matches(valueProvider))
+      if (m.matches(feature))
       {
         return true;
       }
@@ -58,7 +59,7 @@ public class KeyedMatcherSet implements KeyedMatcherSetI
   }
 
   @Override
-  public KeyedMatcherSetI and(KeyedMatcherI m)
+  public FeatureMatcherSetI and(FeatureMatcherI m)
   {
     if (!andConditions && matchConditions.size() > 1)
     {
@@ -71,7 +72,7 @@ public class KeyedMatcherSet implements KeyedMatcherSetI
   }
 
   @Override
-  public KeyedMatcherSetI or(KeyedMatcherI m)
+  public FeatureMatcherSetI or(FeatureMatcherI m)
   {
     if (andConditions && matchConditions.size() > 1)
     {
@@ -90,7 +91,7 @@ public class KeyedMatcherSet implements KeyedMatcherSetI
   }
 
   @Override
-  public Iterable<KeyedMatcherI> getMatchers()
+  public Iterable<FeatureMatcherI> getMatchers()
   {
     return matchConditions;
   }
@@ -100,7 +101,7 @@ public class KeyedMatcherSet implements KeyedMatcherSetI
   {
     StringBuilder sb = new StringBuilder();
     boolean first = true;
-    for (KeyedMatcherI matcher : matchConditions)
+    for (FeatureMatcherI matcher : matchConditions)
     {
       if (!first)
       {