public Predicate createIncludesExcludes()

in arthur-impl/src/main/java/org/apache/geronimo/arthur/impl/nativeimage/generator/DefautContext.java [209:230]


    public Predicate<String> createIncludesExcludes(final String propertyBase, final ArthurExtension.PredicateType type) {
        final Optional<Predicate<String>> includes = createPredicate(propertyBase + "includes", type);
        final Optional<Predicate<String>> excludes = createPredicate(propertyBase + "excludes", type);
        return n -> {
            final boolean hasInclude = includes.isPresent();
            if (hasInclude) {
                if (includes.orElseThrow(IllegalStateException::new).test(n)) {
                    return true;
                }
            }
            final boolean hasExclude = excludes.isPresent();
            if (hasExclude) {
                if (excludes.orElseThrow(IllegalStateException::new).test(n)) {
                    return false;
                }
            }
            if (hasExclude && !hasInclude) {
                return true;
            }
            return !hasExclude && !hasInclude;
        };
    }