@Test public void testParse() { SimpleConstraintParser parser = new SimpleConstraintParser(); check(parser.parse("m1 GT 1"), "m1", Operator.GT, "1"); check(parser.parse("m1 GT (1)"), "m1", Operator.GT, "1"); check(parser.parse("m2 GE 2"), "m2", Operator.GE, "2"); check(parser.parse("m2 GE (2)"), "m2", Operator.GE, "2"); check(parser.parse("m3 EQ 3"), "m3", Operator.EQ, "3"); check(parser.parse("m3 EQ (3)"), "m3", Operator.EQ, "3"); check(parser.parse("m4 LT 4"), "m4", Operator.LT, "4"); check(parser.parse("m4 LT (4)"), "m4", Operator.LT, "4"); check(parser.parse("m5 LE 5"), "m5", Operator.LE, "5"); check(parser.parse("m5 LE (5)"), "m5", Operator.LE, "5"); check(parser.parse("m6 NE 6"), "m6", Operator.NE, "6"); check(parser.parse("m6 NE (6)"), "m6", Operator.NE, "6"); check(parser.parse("latency LT 0.5"), "latency", Operator.LT, "0.5"); check(parser.parse("latency LT (0.5)"), "latency", Operator.LT, "0.5"); check(parser.parse("val IN 1"), "val", Operator.IN, "1"); check(parser.parse("val IN (1)"), "val", Operator.IN, "1"); check(parser.parse("val IN (1,2)"), "val", Operator.IN, "1,2"); check(parser.parse("val IN (1,2,3)"), "val", Operator.IN, "1,2,3"); check(parser.parse("val BETWEEN (1,2)"), "val", Operator.BETWEEN, "1,2"); check(parser.parse("val EXISTS"), "val", Operator.EXISTS, ""); check(parser.parse("val NOT_EXISTS"), "val", Operator.NOT_EXISTS, ""); check(parser.parse("val BETWEEN 1,2"), "val", Operator.BETWEEN, "1,2"); check(parser.parse("val BETWEEN 1,2 "), "val", Operator.BETWEEN, "1,2"); check(parser.parse("val BETWEEN 1 ,2"), "val", Operator.BETWEEN, "1,2"); check(parser.parse("val BETWEEN 1, 2"), "val", Operator.BETWEEN, "1,2"); check(parser.parse("val IN 1 , 2 , 3 "), "val", Operator.IN, "1,2,3"); check(parser.parse("val EXISTS "), "val", Operator.EXISTS, ""); check(parser.parse("val NOT_EXISTS "), "val", Operator.NOT_EXISTS, ""); }
public SimpleConstraintParser.SimpleConstraintElements parse(String constraint) { SimpleConstraintParser.SimpleConstraintElements result; Matcher m = re.matcher(constraint); try { if (m.matches()) { Operator op = Operator.valueOf(m.group(2)); String right = getRightOperandGroup(m); result = new SimpleConstraintParser.SimpleConstraintElements( m.group(1), op, right); return result; } } catch (Exception e) { } throw new IllegalArgumentException("[" + constraint + "] is not a valid constraint"); }
SimpleConstraintParser { public SimpleConstraintParser.SimpleConstraintElements parse(String constraint) { SimpleConstraintParser.SimpleConstraintElements result; Matcher m = re.matcher(constraint); try { if (m.matches()) { Operator op = Operator.valueOf(m.group(2)); String right = getRightOperandGroup(m); result = new SimpleConstraintParser.SimpleConstraintElements( m.group(1), op, right); return result; } } catch (Exception e) { } throw new IllegalArgumentException("[" + constraint + "] is not a valid constraint"); } }
SimpleConstraintParser { public SimpleConstraintParser.SimpleConstraintElements parse(String constraint) { SimpleConstraintParser.SimpleConstraintElements result; Matcher m = re.matcher(constraint); try { if (m.matches()) { Operator op = Operator.valueOf(m.group(2)); String right = getRightOperandGroup(m); result = new SimpleConstraintParser.SimpleConstraintElements( m.group(1), op, right); return result; } } catch (Exception e) { } throw new IllegalArgumentException("[" + constraint + "] is not a valid constraint"); }  }
SimpleConstraintParser { public SimpleConstraintParser.SimpleConstraintElements parse(String constraint) { SimpleConstraintParser.SimpleConstraintElements result; Matcher m = re.matcher(constraint); try { if (m.matches()) { Operator op = Operator.valueOf(m.group(2)); String right = getRightOperandGroup(m); result = new SimpleConstraintParser.SimpleConstraintElements( m.group(1), op, right); return result; } } catch (Exception e) { } throw new IllegalArgumentException("[" + constraint + "] is not a valid constraint"); }  SimpleConstraintParser.SimpleConstraintElements parse(String constraint); }
SimpleConstraintParser { public SimpleConstraintParser.SimpleConstraintElements parse(String constraint) { SimpleConstraintParser.SimpleConstraintElements result; Matcher m = re.matcher(constraint); try { if (m.matches()) { Operator op = Operator.valueOf(m.group(2)); String right = getRightOperandGroup(m); result = new SimpleConstraintParser.SimpleConstraintElements( m.group(1), op, right); return result; } } catch (Exception e) { } throw new IllegalArgumentException("[" + constraint + "] is not a valid constraint"); }  SimpleConstraintParser.SimpleConstraintElements parse(String constraint);  }