Skip to content

Commit

Permalink
Add filematcher group
Browse files Browse the repository at this point in the history
  • Loading branch information
issy committed Nov 19, 2024
1 parent 2f20832 commit eeaa3e5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/issy/compiler/FileMatcherGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.issy.compiler;

import java.util.List;

public record FileMatcherGroup(GroupMode groupMode, List<FileMatcher> 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));
};
}

}

0 comments on commit eeaa3e5

Please sign in to comment.