Class ArtifactCoordsPattern

java.lang.Object
io.quarkus.maven.dependency.ArtifactCoordsPattern

public class ArtifactCoordsPattern extends Object
A general purpose pattern for matching artifact coordinates (i.e. quintupless consisting of groupId, artifactId, classifier, type and version).

To create a new ArtifactCoordsPattern, use either of(String) or builder(), both of which accept wildcard patterns (rather than regular expression patterns). See the JavaDocs of the two respective methods for more details.

ArtifactCoordsPattern overrides hashCode() and equals(Object) and can thus be used as a key in a Map.

  • Method Details

    • builder

      public static ArtifactCoordsPattern.Builder builder()
      Returns:
      a new ArtifactCoordsPattern.Builder
    • of

      public static ArtifactCoordsPattern of(ArtifactCoords c)
    • toPatterns

      public static List<ArtifactCoordsPattern> toPatterns(Collection<ArtifactCoords> coords)
    • matchAll

      public static ArtifactCoordsPattern matchAll()
      Returns:
      a singleton that matches all possible GAVs
    • matchSnapshots

      public static ArtifactCoordsPattern matchSnapshots()
      Returns:
      a singleton that matches any GAV that has a version ending with "-SNAPSHOT"
    • of

      public static ArtifactCoordsPattern of(String wildcardPattern)
      Creates a new ArtifactCoordsPattern out of the given wildcardPattern. A wildcard pattern consists of string literals and asterisk wildcard *. * matches zero or many arbitrary characters. Wildcard patterns for groupId, artifactId, classifier, type and version need to be delimited by colon ':'.

      The general syntax of a ArtifactCoordsPattern follows the pattern groupIdPattern:[artifactIdPattern:[[classifierIdPattern:typePattern]:versionPattern]]. Note that classifier and type need to be specified both or none and that they may occur on the third and fourth position respectively. Hence a ArtifactCoordsPattern with three segments org.my-group:my-artifact:1.2.3 is a short hand for org.my-group:my-artifact:*:*:1.2.3 matching any type and any classifier.

      ArtifactCoordsPattern pattern examples:

      org.my-group - an equivalent of org.my-group:*:*:*. It will match any version of any artifact having groupId org.my-group.

      org.my-group* - an equivalent of org.my-group*:*:*:*. It will match any version of any artifact whose groupId starts with org.my-group - i.e. it will match all of org.my-group, org.my-group.api, org.my-group.impl, etc.

      org.my-group:my-artifact - an equivalent of org.my-group:my-artifact:*. It will match any version of all such artifacts that have groupId org.my-group and artifactId my-artifact

      org.my-group:my-artifact:1.2.3 - will match just the version 1.2.3 of artifacts org.my-group:my-artifact.

      org.my-group:my-artifact:linux-x86_64:*:1.2.3 - will match artifacts of all types having classifier linux-x86_64 and version 1.2.3 of org.my-group:my-artifact.

      org.my-group:my-artifact::*:1.2.3 - will match artifacts of all types having no classifier and version 1.2.3 of org.my-group:my-artifact.

      org.my-group:my-artifact:jar:1.2.3 - Illegal because both type and classifier have to be specified.

      org.my-group:my-artifact::jar:1.2.3 - will match the jar having no classifier and version 1.2.3 of org.my-group:my-artifact.

      Parameters:
      wildcardPattern - a string pattern to parse and create a new ArtifactCoordsPattern from
      Returns:
      a new ArtifactCoordsPattern
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • matches

      public boolean matches(ArtifactCoords coords)
      Matches the given groupId, artifactId, type, classifier, version quintuple against this ArtifactCoordsPattern.
      Parameters:
      coords - artifact coordinates
      Returns:
      true if this ArtifactCoordsPattern matches the given coordinates, otherwise - false
    • matches

      public boolean matches(String groupId, String artifactId, String classifier, String type, String version)
      Matches the given groupId, artifactId, type, classifier, version quintuple against this ArtifactCoordsPattern.
      Parameters:
      groupId - groupId
      artifactId - artifactId
      classifier - can be null
      type - cannot be null
      version - version
      Returns:
      true if this ArtifactCoordsPattern matches the given groupId, artifactId, type, classifier, version quintuple and false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object