@Test public void testMatches() { IntegerType intType = new IntegerType(); StringType strType = new StringType(); Matcher m1ii = new BetweenMatcher(true, true, ":-,"); Matcher m2ie = new BetweenMatcher(true, false, ""); Matcher m3ee = new BetweenMatcher(false, false, null); Object[][] tests = { {"1200 : 1300", "1200", m1ii, intType, true}, {"1200 : 1300", "1250", m1ii, intType, true}, {"1200 : 1300", "1300", m1ii, intType, true}, {"1200 : 1300", "1199", m1ii, intType, false}, {"1200 : 1300", "1301", m1ii, intType, false}, {"1200 ~ 1300", "1200", m2ie, intType, true}, {"1200 ~ 1300", "1250", m2ie, intType, true}, {"1200 ~ 1300", "1300", m2ie, intType, false}, {"1200 ~ 1300", "1199", m2ie, intType, false}, {"1200 ~ 1300", "1301", m2ie, intType, false}, {"1200 ~ 1300", "1200", m3ee, intType, false}, {"1200 ~ 1300", "1250", m3ee, intType, true}, {"1200 ~ 1300", "1300", m3ee, intType, false}, {"1200 ~ 1300", "1199", m3ee, intType, false}, {"1200 ~ 1300", "1301", m3ee, intType, false}, {"1200 : * ", "1200", m1ii, intType, true}, {"1200 :* ", "1199", m1ii, intType, false}, {"* :1300 ", "1250", m1ii, intType, true}, {"*: 1300 ", "1999", m1ii, intType, false}, {" 1200 : ", "1300", m1ii, intType, true}, {" 1200 : ", "1100", m1ii, intType, false}, {" : 1300 ", "1250", m1ii, intType, true}, {" : 1300 ", "1999", m1ii, intType, false}, {" 1200 ", "1300", m1ii, intType, true}, {" 1200 ", "1100", m1ii, intType, false}, {"1200 : * ", "1200", m1ii, strType, true}, {"1200 :* ", "1199", m1ii, strType, false}, {"* :1300 ", "1250", m1ii, strType, true}, {"*: 1300 ", "1999", m1ii, strType, false}, {" 1200 : ", "1300", m1ii, strType, true}, {" 1200 : ", "1100", m1ii, strType, false}, {" : 1300 ", "1250", m1ii, strType, true}, {" : 1300 ", "1999", m1ii, strType, false}, {" 1200 ", "1300", m1ii, strType, true}, {" 1200 ", "1100", m1ii, strType, false}, {"aa:abaaa", "a", m1ii, strType, false}, {"aa:abaaa", "aa", m1ii, strType, true}, {"aa:abaaa", "aaa", m1ii, strType, true}, {"aa:abaaa", "aaaa", m1ii, strType, true}, {"aa:abaaa", "abaaa", m1ii, strType, true}, {"aa:abaaa", "abaab", m1ii, strType, false}, {"1200 - 1300", "1200", m1ii, intType, true}, {"1200 - 1300", "1250", m1ii, intType, true}, {"1200 , 1300", "1300", m1ii, intType, true}, {"1200- 1300 ", "1199", m1ii, intType, false}, {" 1200:1300 ", "1301", m1ii, intType, false} }; for (Object[] test : tests) { String pattern = (String) test[0]; String value = (String) test[1]; Matcher matcher = (Matcher) test[2]; Type<?> type = (Type<?>) test[3]; boolean expectedResult = (Boolean) test[4]; boolean result = matcher.matches(value, pattern, type); assertEquals(expectedResult, result); } }
@Override public <T extends ValueHolder> boolean matches(String value, String pattern, Type<T> type) { char separator = findSeparator(pattern); String[] tokens = EngineUtil.split2(pattern, separator); String lower = tokens[0].trim(); String upper = tokens[1].trim(); T v = type.decode(value); return lowerCondition(v, lower, type) && upperCondition(v, upper, type); }
BetweenMatcher implements Matcher { @Override public <T extends ValueHolder> boolean matches(String value, String pattern, Type<T> type) { char separator = findSeparator(pattern); String[] tokens = EngineUtil.split2(pattern, separator); String lower = tokens[0].trim(); String upper = tokens[1].trim(); T v = type.decode(value); return lowerCondition(v, lower, type) && upperCondition(v, upper, type); } }
BetweenMatcher implements Matcher { @Override public <T extends ValueHolder> boolean matches(String value, String pattern, Type<T> type) { char separator = findSeparator(pattern); String[] tokens = EngineUtil.split2(pattern, separator); String lower = tokens[0].trim(); String upper = tokens[1].trim(); T v = type.decode(value); return lowerCondition(v, lower, type) && upperCondition(v, upper, type); } BetweenMatcher();  BetweenMatcher(String lowerInclusive, String upperInclusive);  BetweenMatcher(String lowerInclusive, String upperInclusive, String separators);  BetweenMatcher(boolean lowerInclusive, boolean upperInclusive, String separators); }
BetweenMatcher implements Matcher { @Override public <T extends ValueHolder> boolean matches(String value, String pattern, Type<T> type) { char separator = findSeparator(pattern); String[] tokens = EngineUtil.split2(pattern, separator); String lower = tokens[0].trim(); String upper = tokens[1].trim(); T v = type.decode(value); return lowerCondition(v, lower, type) && upperCondition(v, upper, type); } BetweenMatcher();  BetweenMatcher(String lowerInclusive, String upperInclusive);  BetweenMatcher(String lowerInclusive, String upperInclusive, String separators);  BetweenMatcher(boolean lowerInclusive, boolean upperInclusive, String separators); @Override boolean matches(String value, String pattern, Type<T> type); char[] separators(); }
BetweenMatcher implements Matcher { @Override public <T extends ValueHolder> boolean matches(String value, String pattern, Type<T> type) { char separator = findSeparator(pattern); String[] tokens = EngineUtil.split2(pattern, separator); String lower = tokens[0].trim(); String upper = tokens[1].trim(); T v = type.decode(value); return lowerCondition(v, lower, type) && upperCondition(v, upper, type); } BetweenMatcher();  BetweenMatcher(String lowerInclusive, String upperInclusive);  BetweenMatcher(String lowerInclusive, String upperInclusive, String separators);  BetweenMatcher(boolean lowerInclusive, boolean upperInclusive, String separators); @Override boolean matches(String value, String pattern, Type<T> type); char[] separators(); static final String BETWEEN_IE; static final String BETWEEN_EI; static final String BETWEEN_II; static final String BETWEEN_EE; }