All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wildfly.extras.creaper.commands.patching.PatchingConversions Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package org.wildfly.extras.creaper.commands.patching;

import java.util.List;

final class PatchingConversions {
    private PatchingConversions() {} // avoid instantiation

    /**
     * Converts list to single string using comma as delimiter.
     */
    public static String flatten(List list) {
        if (list == null) {
            throw new IllegalArgumentException("Argument list must be provided");
        }
        StringBuilder sb = new StringBuilder();
        for (String p : list) {
            if (sb.length() > 0) {
                sb.append(",");
            }
            sb.append(p);
        }
        return sb.toString();
    }

    /**
     * Converts list of paths to string with comma as delimiter, with escaping of backslashes.
     */
    public static String flattenAndEscape(List paths) {
        if (paths == null) {
            throw new IllegalArgumentException("Argument paths must be provided");
        }
        StringBuilder sb = new StringBuilder();
        for (String p : paths) {
            if (sb.length() > 0) {
                sb.append(",");
            }
            sb.append(p.replaceAll("\\\\", "\\\\\\\\")); //FIXME correct path escaping on Windows?
        }
        return sb.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy