@Test public void testToPredicate() throws Exception { String prop = "prop"; String val = "one,2,three"; EqualsPredicate p1 = new EqualsPredicate<String>(prop, "one"); EqualsPredicate p2 = new EqualsPredicate<String>(prop, "2"); EqualsPredicate p3 = new EqualsPredicate<String>(prop, "three"); OrPredicate orPredicate = new OrPredicate(p1, p2, p3); assertEquals(orPredicate, new InOperator().toPredicate(prop, val)); }
@Override public Predicate toPredicate(String prop, String val) throws InvalidQueryException { if (val == null) { throw new InvalidQueryException("IN operator is missing a required right operand."); } String[] tokens = val.split(","); List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>(); for (String token : tokens) { listPredicates.add(new EqualsPredicate<>(prop, token.trim())); } return listPredicates.size() == 1 ? listPredicates.get(0) : buildOrPredicate(listPredicates); }
InOperator extends AbstractOperator implements RelationalOperator { @Override public Predicate toPredicate(String prop, String val) throws InvalidQueryException { if (val == null) { throw new InvalidQueryException("IN operator is missing a required right operand."); } String[] tokens = val.split(","); List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>(); for (String token : tokens) { listPredicates.add(new EqualsPredicate<>(prop, token.trim())); } return listPredicates.size() == 1 ? listPredicates.get(0) : buildOrPredicate(listPredicates); } }
InOperator extends AbstractOperator implements RelationalOperator { @Override public Predicate toPredicate(String prop, String val) throws InvalidQueryException { if (val == null) { throw new InvalidQueryException("IN operator is missing a required right operand."); } String[] tokens = val.split(","); List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>(); for (String token : tokens) { listPredicates.add(new EqualsPredicate<>(prop, token.trim())); } return listPredicates.size() == 1 ? listPredicates.get(0) : buildOrPredicate(listPredicates); } InOperator(); }
InOperator extends AbstractOperator implements RelationalOperator { @Override public Predicate toPredicate(String prop, String val) throws InvalidQueryException { if (val == null) { throw new InvalidQueryException("IN operator is missing a required right operand."); } String[] tokens = val.split(","); List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>(); for (String token : tokens) { listPredicates.add(new EqualsPredicate<>(prop, token.trim())); } return listPredicates.size() == 1 ? listPredicates.get(0) : buildOrPredicate(listPredicates); } InOperator(); @Override String getName(); @Override Predicate toPredicate(String prop, String val); @Override TYPE getType(); }
InOperator extends AbstractOperator implements RelationalOperator { @Override public Predicate toPredicate(String prop, String val) throws InvalidQueryException { if (val == null) { throw new InvalidQueryException("IN operator is missing a required right operand."); } String[] tokens = val.split(","); List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>(); for (String token : tokens) { listPredicates.add(new EqualsPredicate<>(prop, token.trim())); } return listPredicates.size() == 1 ? listPredicates.get(0) : buildOrPredicate(listPredicates); } InOperator(); @Override String getName(); @Override Predicate toPredicate(String prop, String val); @Override TYPE getType();  }