Class ArtifactMatcher


  • public final class ArtifactMatcher
    extends java.lang.Object
    This class is used for matching Artifacts against a list of patterns.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 - includes
        includeStrings - 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 any excludePatterns and none of the includePatterns, otherwise false
      • 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 any excludePatterns and none of the includePatterns, otherwise false
      • 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.