diff --git a/src/main/java/com/issy/compiler/FileMatcherGroup.java b/src/main/java/com/issy/compiler/FileMatcherGroup.java new file mode 100644 index 0000000..3f21adc --- /dev/null +++ b/src/main/java/com/issy/compiler/FileMatcherGroup.java @@ -0,0 +1,21 @@ +package com.issy.compiler; + +import java.util.List; + +public record FileMatcherGroup(GroupMode groupMode, List fileMatchers) { + + public enum GroupMode { + AND, + OR + } + + public FileMatcher compile() { + return switch (groupMode) { + case AND: + yield filepath -> fileMatchers.stream().allMatch(fileMatcher -> fileMatcher.matches(filepath)); + case OR: + yield filepath -> fileMatchers.stream().anyMatch(fileMatcher -> fileMatcher.matches(filepath)); + }; + } + +}