@Test public void testIsMatchGlobPatternsNeedInterpolate() throws Exception { Collection<String> patternsNeedInterpolate = new HashSet<String>(); Map<String, String> interpolateParams = new HashMap<String, String>(); boolean match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abc"); assertFalse(match); patternsNeedInterpolate.add("abc*$var1"); patternsNeedInterpolate.add("123${var2}*"); interpolateParams.put("var1", "CAT"); interpolateParams.put("var2", "DOG"); match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abc"); assertFalse(match); match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abcXXXCAT"); assertTrue(match); match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "123DOGYYY"); assertTrue(match); }
public static boolean isMatchGlobPatternsNeedInterpolate( Collection<String> patternsNeedInterpolate, Map<String, String> interpolateParams, String value) { if(patternsNeedInterpolate != null && ! patternsNeedInterpolate.isEmpty()) { for (String patternNeedItp : patternsNeedInterpolate) { if(StringUtils.isEmpty(patternNeedItp)) { continue; } String pattern = interpolate(patternNeedItp, interpolateParams); if(isMatchGlobPattern(pattern, value)) { return true; } } } return false; }
ParseUtils { public static boolean isMatchGlobPatternsNeedInterpolate( Collection<String> patternsNeedInterpolate, Map<String, String> interpolateParams, String value) { if(patternsNeedInterpolate != null && ! patternsNeedInterpolate.isEmpty()) { for (String patternNeedItp : patternsNeedInterpolate) { if(StringUtils.isEmpty(patternNeedItp)) { continue; } String pattern = interpolate(patternNeedItp, interpolateParams); if(isMatchGlobPattern(pattern, value)) { return true; } } } return false; } }
ParseUtils { public static boolean isMatchGlobPatternsNeedInterpolate( Collection<String> patternsNeedInterpolate, Map<String, String> interpolateParams, String value) { if(patternsNeedInterpolate != null && ! patternsNeedInterpolate.isEmpty()) { for (String patternNeedItp : patternsNeedInterpolate) { if(StringUtils.isEmpty(patternNeedItp)) { continue; } String pattern = interpolate(patternNeedItp, interpolateParams); if(isMatchGlobPattern(pattern, value)) { return true; } } } return false; } private  ParseUtils(); }
ParseUtils { public static boolean isMatchGlobPatternsNeedInterpolate( Collection<String> patternsNeedInterpolate, Map<String, String> interpolateParams, String value) { if(patternsNeedInterpolate != null && ! patternsNeedInterpolate.isEmpty()) { for (String patternNeedItp : patternsNeedInterpolate) { if(StringUtils.isEmpty(patternNeedItp)) { continue; } String pattern = interpolate(patternNeedItp, interpolateParams); if(isMatchGlobPattern(pattern, value)) { return true; } } } return false; } private  ParseUtils(); static String interpolate(String expression, Map<String, String> params); static List<String> interpolate(List<String> expressions, Map<String, String> params); static boolean isMatchGlobPattern(String pattern, String value); static boolean isMatchGlobPatternsNeedInterpolate(
            Collection<String> patternsNeedInterpolate,
            Map<String, String> interpolateParams, String value); static Set<String> filterByGlobPattern(String pattern, Collection<String> values); static Set<String> filterByGlobPattern(Collection<String> patterns, Collection<String> values); static boolean hasIntersection(String glob1, String glob2); static Map<String, String> parseQuery(String keyPrefix, String query); static Map<String, String> parseQuery(String query); static String replaceParameter(String query, String key, String value); static String appendParamToUri(String uri, String name, String value); static String appendParamsToUri(String uri, Map<String, String> params); static boolean matchEndStarPattern(String value, String pattern); }
ParseUtils { public static boolean isMatchGlobPatternsNeedInterpolate( Collection<String> patternsNeedInterpolate, Map<String, String> interpolateParams, String value) { if(patternsNeedInterpolate != null && ! patternsNeedInterpolate.isEmpty()) { for (String patternNeedItp : patternsNeedInterpolate) { if(StringUtils.isEmpty(patternNeedItp)) { continue; } String pattern = interpolate(patternNeedItp, interpolateParams); if(isMatchGlobPattern(pattern, value)) { return true; } } } return false; } private  ParseUtils(); static String interpolate(String expression, Map<String, String> params); static List<String> interpolate(List<String> expressions, Map<String, String> params); static boolean isMatchGlobPattern(String pattern, String value); static boolean isMatchGlobPatternsNeedInterpolate(
            Collection<String> patternsNeedInterpolate,
            Map<String, String> interpolateParams, String value); static Set<String> filterByGlobPattern(String pattern, Collection<String> values); static Set<String> filterByGlobPattern(Collection<String> patterns, Collection<String> values); static boolean hasIntersection(String glob1, String glob2); static Map<String, String> parseQuery(String keyPrefix, String query); static Map<String, String> parseQuery(String query); static String replaceParameter(String query, String key, String value); static String appendParamToUri(String uri, String name, String value); static String appendParamsToUri(String uri, Map<String, String> params); static boolean matchEndStarPattern(String value, String pattern); static String METHOD_SPLIT; }