@Test public void testLessThan() throws Exception { IntegerValueMatcher matcher = new IntegerValueMatcher(); assertEquals(LESS_THAN, matcher.getNextServiceId("4", create())); }
public String getNextServiceId(String serviceKey, KeyValuePairBag mappings) { String result = null; Integer lhs = null; Integer rhs = null; try { lhs = Integer.parseInt(serviceKey); } catch (NumberFormatException e) { logR.trace("[{}] not parseable as an integer", serviceKey); return result; } Pattern matchPattern = Pattern.compile(INTEGER_OPERATOR_PATTERN); Set<KeyValuePair> pairs = sort(mappings); for (KeyValuePair kvp : pairs) { Matcher m = matchPattern.matcher(kvp.getKey()); if (m.matches()) { String operator = m.group(1); rhs = Integer.parseInt(m.group(2)); Operator o = OPERATORS.get(operator); if (o == null) { logR.trace("[{}] not handled, ignoring", kvp.getKey()); continue; } logR.trace("Comparing [{}] against [{}] using {}", lhs, rhs, o.toString()); if (o.matches(lhs, rhs)) { result = kvp.getValue(); break; } } else { logR.trace("Ignoring {}, no match for regular expression [{}]", kvp.getKey(), INTEGER_OPERATOR_PATTERN); } } return result; }
IntegerValueMatcher implements MetadataValueMatcher { public String getNextServiceId(String serviceKey, KeyValuePairBag mappings) { String result = null; Integer lhs = null; Integer rhs = null; try { lhs = Integer.parseInt(serviceKey); } catch (NumberFormatException e) { logR.trace("[{}] not parseable as an integer", serviceKey); return result; } Pattern matchPattern = Pattern.compile(INTEGER_OPERATOR_PATTERN); Set<KeyValuePair> pairs = sort(mappings); for (KeyValuePair kvp : pairs) { Matcher m = matchPattern.matcher(kvp.getKey()); if (m.matches()) { String operator = m.group(1); rhs = Integer.parseInt(m.group(2)); Operator o = OPERATORS.get(operator); if (o == null) { logR.trace("[{}] not handled, ignoring", kvp.getKey()); continue; } logR.trace("Comparing [{}] against [{}] using {}", lhs, rhs, o.toString()); if (o.matches(lhs, rhs)) { result = kvp.getValue(); break; } } else { logR.trace("Ignoring {}, no match for regular expression [{}]", kvp.getKey(), INTEGER_OPERATOR_PATTERN); } } return result; } }
IntegerValueMatcher implements MetadataValueMatcher { public String getNextServiceId(String serviceKey, KeyValuePairBag mappings) { String result = null; Integer lhs = null; Integer rhs = null; try { lhs = Integer.parseInt(serviceKey); } catch (NumberFormatException e) { logR.trace("[{}] not parseable as an integer", serviceKey); return result; } Pattern matchPattern = Pattern.compile(INTEGER_OPERATOR_PATTERN); Set<KeyValuePair> pairs = sort(mappings); for (KeyValuePair kvp : pairs) { Matcher m = matchPattern.matcher(kvp.getKey()); if (m.matches()) { String operator = m.group(1); rhs = Integer.parseInt(m.group(2)); Operator o = OPERATORS.get(operator); if (o == null) { logR.trace("[{}] not handled, ignoring", kvp.getKey()); continue; } logR.trace("Comparing [{}] against [{}] using {}", lhs, rhs, o.toString()); if (o.matches(lhs, rhs)) { result = kvp.getValue(); break; } } else { logR.trace("Ignoring {}, no match for regular expression [{}]", kvp.getKey(), INTEGER_OPERATOR_PATTERN); } } return result; } IntegerValueMatcher(); }
IntegerValueMatcher implements MetadataValueMatcher { public String getNextServiceId(String serviceKey, KeyValuePairBag mappings) { String result = null; Integer lhs = null; Integer rhs = null; try { lhs = Integer.parseInt(serviceKey); } catch (NumberFormatException e) { logR.trace("[{}] not parseable as an integer", serviceKey); return result; } Pattern matchPattern = Pattern.compile(INTEGER_OPERATOR_PATTERN); Set<KeyValuePair> pairs = sort(mappings); for (KeyValuePair kvp : pairs) { Matcher m = matchPattern.matcher(kvp.getKey()); if (m.matches()) { String operator = m.group(1); rhs = Integer.parseInt(m.group(2)); Operator o = OPERATORS.get(operator); if (o == null) { logR.trace("[{}] not handled, ignoring", kvp.getKey()); continue; } logR.trace("Comparing [{}] against [{}] using {}", lhs, rhs, o.toString()); if (o.matches(lhs, rhs)) { result = kvp.getValue(); break; } } else { logR.trace("Ignoring {}, no match for regular expression [{}]", kvp.getKey(), INTEGER_OPERATOR_PATTERN); } } return result; } IntegerValueMatcher(); String getNextServiceId(String serviceKey, KeyValuePairBag mappings); }
IntegerValueMatcher implements MetadataValueMatcher { public String getNextServiceId(String serviceKey, KeyValuePairBag mappings) { String result = null; Integer lhs = null; Integer rhs = null; try { lhs = Integer.parseInt(serviceKey); } catch (NumberFormatException e) { logR.trace("[{}] not parseable as an integer", serviceKey); return result; } Pattern matchPattern = Pattern.compile(INTEGER_OPERATOR_PATTERN); Set<KeyValuePair> pairs = sort(mappings); for (KeyValuePair kvp : pairs) { Matcher m = matchPattern.matcher(kvp.getKey()); if (m.matches()) { String operator = m.group(1); rhs = Integer.parseInt(m.group(2)); Operator o = OPERATORS.get(operator); if (o == null) { logR.trace("[{}] not handled, ignoring", kvp.getKey()); continue; } logR.trace("Comparing [{}] against [{}] using {}", lhs, rhs, o.toString()); if (o.matches(lhs, rhs)) { result = kvp.getValue(); break; } } else { logR.trace("Ignoring {}, no match for regular expression [{}]", kvp.getKey(), INTEGER_OPERATOR_PATTERN); } } return result; } IntegerValueMatcher(); String getNextServiceId(String serviceKey, KeyValuePairBag mappings);  }