public static PreProcessor changePrefix(String from, String to) {
        return mkPreProcessorWithMeta((prefix, data, options) -> {
            logger.debug("changing prefix at '{}' from '{}' to '{}'", prefix, from, to);

            return data.entrySet().stream()
                    .map(e -> {
                        if (!e.getKey().startsWith(prefix)) return e;
                        else {
                            String tail = e.getKey().substring(prefix.length())
                                    .replaceFirst("^[\\.]?" + Pattern.quote(from), to)
                                    .replaceFirst("^\\.", "");
                            String newKey = isEmptyStr(tail) ? prefix
                                    : (prefix + "." + tail).replaceFirst("^\\.", "");
                            return entry(
                                    newKey,
                                    e.getValue()
                            );
                        }
                    }).collect(Collectors.toMap(
                            Map.Entry::getKey,
                            Map.Entry::getValue
                    ));
            }, new ExtensionMeta(PRE_PROCESSOR_CHANGE_PREFIX,
                    "changePrefix(from '" +from+ "' to '" +to+ "')",
                    Arrays.asList(from, to)));
        }
public static PreProcessor changePrefix ( String from , String to ) { return mkPreProcessorWithMeta ( ( prefix , data , options ) -> { logger . debug ( "changing prefix at '{}' from '{}' to '{}'" , prefix , from , to ) ; return data . entrySet ( ) . stream ( ) . map ( e -> { if ( ! e . getKey ( ) . startsWith ( prefix ) ) return e ; else { String tail = e . getKey ( ) . substring ( prefix . length ( ) ) . replaceFirst ( "^[\\.]?" + Pattern . quote ( from ) , to ) . replaceFirst ( "^\\." , "" ) ; String newKey = isEmptyStr ( tail ) ? prefix : ( prefix + "." + tail ) . replaceFirst ( "^\\." , "" ) ; return entry ( newKey , e . getValue ( ) ) ; } } ) . collect ( Collectors . toMap ( Map . Entry :: getKey , Map . Entry :: getValue ) ) ; } , new ExtensionMeta ( PRE_PROCESSOR_CHANGE_PREFIX , "changePrefix(from '" + from + "' to '" + to + "')" , Arrays . asList ( from , to ) ) ) ; }
change data key prefix from one to other
@param from from prefix
@param to to prefix
@return new created pre-processor