From eeaa3e522c8b7e13bf12481dca62679eed1d19a0 Mon Sep 17 00:00:00 2001 From: Issy Szemeti Date: Tue, 19 Nov 2024 08:48:12 +0000 Subject: [PATCH] Add filematcher group --- .../com/issy/compiler/FileMatcherGroup.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/com/issy/compiler/FileMatcherGroup.java 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)); + }; + } + +}