private List parseMatches()

in src/main/java/org/apache/sling/feature/maven/mojos/selection/IncludeExcludeMatcher.java [50:83]


    private List<String[]> parseMatches(final List<String> patterns,
            final String separator,
            final boolean separatorRequired) throws MojoExecutionException {
        List<String[]> matches = null;
        if (patterns != null && !patterns.isEmpty()) {
            matches = new ArrayList<>();
            for (final String t : patterns) {
                final String[] parts;
                if (separator == null ) {
                    parts = new String[] {t, ""};
                } else if (t.endsWith(separator)) {
                    parts = new String[] {t.substring(0, t.length() - 1), ""};
                } else if ( t.contains(separator) ) {
                    parts = t.split(separator);
                } else if ( separatorRequired ) {
                    throw new MojoExecutionException("Illegal pattern: " + t);
                } else {
                    parts = new String[] {t, ""};
                }
                if ( parts.length != 2 ) {
                    throw new MojoExecutionException("Illegal pattern: " + t);
                }
                final String[] val = parts[0].split(":");
                if (val.length > 5) {
                    throw new MojoExecutionException("Illegal pattern: " + t);
                }
                final String[] result = new String[val.length + 1];
                System.arraycopy(val, 0, result, 1, val.length);
                result[0] = parts[1];
                matches.add(result);
            }
        }
        return matches;
    }