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

tech.kronicle.utils.AntStyleIgnoreFileLoader Maven / Gradle / Ivy

Go to download

Kronicle utils library that contains utility classes for use by Kronicle and its plugins

There is a newer version: 0.1.331
Show newest version
package tech.kronicle.utils;

import java.util.List;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class AntStyleIgnoreFileLoader {

    // "\\R" matches any Unicode line-break sequence on Java 8+
    private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\\R");
    private static final Pattern COMMENT_LINE_PATTERN = Pattern.compile("^\\s*#");
    private static final Pattern EMPTY_LINE_PATTERN = Pattern.compile("^\\s*$");
    public static final Predicate NOT_COMMENT_LINE = Predicate.not(COMMENT_LINE_PATTERN.asPredicate());
    public static final Predicate NOT_EMPTY_LINE = Predicate.not(EMPTY_LINE_PATTERN.asPredicate());

    public List load(String content) {
        return LINE_BREAK_PATTERN.splitAsStream(content)
                .filter(NOT_COMMENT_LINE)
                .filter(NOT_EMPTY_LINE)
                .collect(Collectors.toUnmodifiableList());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy