Skip to content

Commit

Permalink
Linting and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Aug 16, 2024
1 parent 0df51f2 commit f2c89e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
public interface IncludesExcludesPattern {

/**
* Returns an IncludesExcludes file matcher that matches files following the patterns against a
* root folder.
* Returns an IncludesExcludes file matcher that matches files following the patterns specified
* patterns. The patterns must follow the java's {@link java.nio.file.PathMatcher} specification
* and are treated as relative paths with regard to the repository root.
*/
public IncludesExcludes getRootedMatcher(final Path root);
IncludesExcludes getRootedMatcher(final Path root);

class Default implements IncludesExcludesPattern {

Expand All @@ -34,9 +35,12 @@ public IncludesExcludes getRootedMatcher(final Path root) {
}
}

/** An includes/excludes pattern that matches java files. */
final class JavaMatcherSingleton {
private static IncludesExcludesPattern singleton;

private JavaMatcherSingleton() {}

public static IncludesExcludesPattern getInstance() {
if (singleton == null) {
singleton =
Expand All @@ -47,9 +51,12 @@ public static IncludesExcludesPattern getInstance() {
}
}

/** An includes/excludes pattern that matches any files. */
final class AnySingleton {
private static IncludesExcludesPattern singleton;

private AnySingleton() {}

public static IncludesExcludesPattern getInstance() {
if (singleton == null) {
singleton = new IncludesExcludesPattern.Default(Set.of("**"), Collections.emptySet());
Expand All @@ -58,11 +65,13 @@ public static IncludesExcludesPattern getInstance() {
}
}

public static IncludesExcludesPattern getJavaMatcher() {
/** Returns an includes/excludes pattern that matches any java files. */
static IncludesExcludesPattern getJavaMatcher() {
return JavaMatcherSingleton.getInstance();
}

public static IncludesExcludesPattern getAnyMatcher() {
/** Returns an includes/excludes pattern that matches any files. */
static IncludesExcludesPattern getAnyMatcher() {
return AnySingleton.getInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import java.io.LineNumberReader;
import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -33,7 +31,6 @@ protected RegexFileChanger(
}

protected RegexFileChanger(
final Predicate<Path> fileMatcher,
final Pattern pattern,
final boolean removeEmptyLeftoverLines,
final List<DependencyGAV> dependenciesRequired,
Expand Down

0 comments on commit f2c89e4

Please sign in to comment.