gora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From renato2099 <...@git.apache.org>
Subject [GitHub] gora pull request: GORA-454 Implement FilterList tests
Date Mon, 11 Jan 2016 12:46:41 GMT
Github user renato2099 commented on a diff in the pull request:

    https://github.com/apache/gora/pull/48#discussion_r49316977
  
    --- Diff: gora-core/src/main/java/org/apache/gora/filter/FilterList.java ---
    @@ -101,8 +109,25 @@ public void write(DataOutput out) throws IOException {
     
       @Override
       public boolean filter(K key, T persistent) {
    -    // TODO not yet implemented
    -    return false;
    +    boolean filtered = false;
    +    //OR
    +    if (operator.equals(Operator.MUST_PASS_ONE)) {
    +      for (Filter<K, T> filter: filters) {
    +        if (!filter.filter(key, persistent)) {
    +          return !filtered;
    +        }
    +      }
    +      //AND
    +    } else if (operator.equals(Operator.MUST_PASS_ALL)) {
    +      for (Filter<K, T> filter: filters) {
    +        if (filter.filter(key, persistent)) {
    +          return !filtered;
    +        }
    +      }
    +    } else {
    +      throw new IllegalStateException(operator + " not yet implemented!");
    +    }
    +    return filtered;
       }
    --- End diff --
    
    I think this looks good, just being annoying here, but would it look more readable if
we have a switch statement instead?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message