Example usage for org.apache.commons.collections15 CollectionUtils transform

List of usage examples for org.apache.commons.collections15 CollectionUtils transform

Introduction

In this page you can find the example usage for org.apache.commons.collections15 CollectionUtils transform.

Prototype

public static <E> void transform(Collection<E> collection, Transformer<? super E, ? extends E> transformer) 

Source Link

Document

Transform the collection by applying a Transformer to each element.

Usage

From source file:org.dllearner.confparser.PostProcessor.java

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();/*from   w  ww . j a  va  2  s  . co m*/
    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;
}

From source file:org.dllearner.confparser.PostProcessor.java

@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);
        }/*from  ww w .  ja v  a2s.c o  m*/
        return input;
    });
}