@Override public List<String> transform(List<String> resource) { List<String> copy = new ArrayList<String>(resource); CollectionUtils.transform(copy, new Transformer<String, String>() { public String transform(String input) { return StringUtils.trim(input); } }); return copy; }
@SuppressWarnings("unchecked") private void processStringCollection(final Map<String, String> prefixes, Collection valueObject) { CollectionUtils.transform(valueObject, input -> { if (input instanceof String) { return replaceAllMap("", prefixes, ":", (String) input); } return input; }); } }
private static String replaceAllMap (String pre, Map<String,String> repMap, String post, String in) { List<String> keys = new ArrayList<>(repMap.keySet()); Collections.sort(keys, (o1, o2) -> o1.length() - o2.length()); CollectionUtils.transform(keys, input -> Pattern.quote(input)); Matcher m = Pattern.compile(pre + "(" + Strings.join(keys, "|") + ")" + post).matcher(in); m.reset(); if (m.find()) { StringBuffer sb = new StringBuffer(); do { m.appendReplacement(sb, repMap.get(m.group(1))); } while (m.find()); return m.appendTail(sb).toString(); } return in; }
@Override public List<String> transform(final List<String> resource) { List<String> copy = new ArrayList<String>(resource); CollectionUtils.filter(copy, new Predicate<String>() { public boolean evaluate(String object) { return SCRIPTS_EXTRACT_PATTERN.matcher((String) object) .matches(); } }); CollectionUtils.transform(copy, new Transformer<String, String>() { public String transform(String input) { Matcher matcher = SCRIPTS_EXTRACT_PATTERN .matcher((String) input); if (matcher.matches()) { String transformed = StringUtils.isEmpty(getPrefix()) ? StringUtils.EMPTY : "/" + getPrefix(); return new StringBuilder(transformed).append("/") //$NON-NLS-1$ .append(matcher.group(2)).toString(); } return null; } }); return copy; }