Class ArtifactMatcher
- java.lang.Object
-
- org.apache.maven.enforcer.rules.utils.ArtifactMatcher
-
public final class ArtifactMatcher extends java.lang.Object
This class is used for matching Artifacts against a list of patterns.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ArtifactMatcher.Pattern
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<ArtifactMatcher.Pattern>
excludePatterns
private java.util.Collection<ArtifactMatcher.Pattern>
includePatterns
-
Constructor Summary
Constructors Constructor Description ArtifactMatcher(java.util.Collection<java.lang.String> excludeStrings, java.util.Collection<java.lang.String> includeStrings)
Construct class by providing patterns as strings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
containsVersion(org.apache.maven.artifact.versioning.VersionRange allowedRange, org.apache.maven.artifact.versioning.ArtifactVersion theVersion)
Copied from Artifact.VersionRange.private boolean
match(java.util.function.Function<ArtifactMatcher.Pattern,java.lang.Boolean> matcher)
boolean
match(org.apache.maven.artifact.Artifact artifact)
Check if artifact matches patterns.boolean
match(org.apache.maven.model.Dependency dependency)
Check if dependency matches patterns.
-
-
-
Field Detail
-
excludePatterns
private final java.util.Collection<ArtifactMatcher.Pattern> excludePatterns
-
includePatterns
private final java.util.Collection<ArtifactMatcher.Pattern> includePatterns
-
-
Constructor Detail
-
ArtifactMatcher
public ArtifactMatcher(java.util.Collection<java.lang.String> excludeStrings, java.util.Collection<java.lang.String> includeStrings)
Construct class by providing patterns as strings. Empty strings are ignored.- Parameters:
excludeStrings
- includesincludeStrings
- excludes- Throws:
java.lang.NullPointerException
- if any of the arguments is null
-
-
Method Detail
-
match
private boolean match(java.util.function.Function<ArtifactMatcher.Pattern,java.lang.Boolean> matcher)
-
match
public boolean match(org.apache.maven.artifact.Artifact artifact)
Check if artifact matches patterns.- Parameters:
artifact
- the artifact to match- Returns:
true
if artifact matches anyexcludePatterns
and none of theincludePatterns
, otherwisefalse
-
match
public boolean match(org.apache.maven.model.Dependency dependency)
Check if dependency matches patterns.- Parameters:
dependency
- the dependency to match- Returns:
true
if dependency matches anyexcludePatterns
and none of theincludePatterns
, otherwisefalse
-
containsVersion
public static boolean containsVersion(org.apache.maven.artifact.versioning.VersionRange allowedRange, org.apache.maven.artifact.versioning.ArtifactVersion theVersion)
Copied from Artifact.VersionRange. This is tweaked to handle singular ranges properly. Currently the default containsVersion method assumes a singular version means allow everything. This method assumes that "2.0.4" == "[2.0.4,)"- Parameters:
allowedRange
- range of allowed versions.theVersion
- the version to be checked.- Returns:
- true if the version is contained by the range.
-
-