private static boolean matchCondition(BackendEntry item, Condition c) { // TODO: Compatible with BackendEntry TextBackendEntry entry = (TextBackendEntry) item; // Not supported by memory if (!(c instanceof Condition.Relation)) { throw new BackendException("Unsupported condition: " + c); } Condition.Relation r = (Condition.Relation) c; String key = r.serialKey().toString(); // TODO: deal with others Relation like: <, >=, ... if (r.relation() == Condition.RelationType.CONTAINS_KEY) { return entry.contains(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.CONTAINS) { return entry.containsValue(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.EQ) { return entry.contains(key, r.serialValue().toString()); } else if (entry.contains(key)) { return r.test(entry.column(key)); } return false; } }
private static boolean matchCondition(BackendEntry item, Condition c) { // TODO: Compatible with BackendEntry TextBackendEntry entry = (TextBackendEntry) item; // Not supported by memory if (!(c instanceof Condition.Relation)) { throw new BackendException("Unsupported condition: " + c); } Condition.Relation r = (Condition.Relation) c; String key = r.serialKey().toString(); // TODO: deal with others Relation like: <, >=, ... if (r.relation() == Condition.RelationType.CONTAINS_KEY) { return entry.contains(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.CONTAINS) { return entry.containsValue(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.EQ) { return entry.contains(key, r.serialValue().toString()); } else if (entry.contains(key)) { return r.test(entry.column(key)); } return false; } }