Class MavenArtifact


  • @Immutable
    public class MavenArtifact
    extends Artifact
    Represents a Maven software artifact with attributes such as group ID, artifact ID, version, and location. This class extends the basic Artifact by adding Maven-specific identification through group ID. It supports matching artifacts based on group ID, in addition to the properties defined in the parent class.

    Example Usage

    
     // Create a Maven artifact with group ID, artifact ID, and default version (UNKNOWN)
     MavenArtifact mavenArtifact1 = MavenArtifact.create("com.example", "my-artifact");
    
     // Create a Maven artifact with group ID, artifact ID, and specific version
     MavenArtifact mavenArtifact2 = MavenArtifact.create("com.example", "my-artifact", "1.0.0");
    
     // Create a Maven artifact with group ID, artifact ID, version, and location
     URL location = new URL("http://example.com/artifact.jar");
     MavenArtifact mavenArtifact3 = MavenArtifact.create("com.example", "my-artifact", "1.0.0", location);
    
     // Matching Maven artifacts based on group ID, artifact ID, and version
     boolean isMatch = mavenArtifact1.matches(mavenArtifact2); // returns false
      
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    Artifact, ArtifactResourceResolver
    • Constructor Detail

      • MavenArtifact

        public MavenArtifact​(@Nonnull
                             java.lang.String groupId,
                             @Nonnull
                             java.lang.String artifactId,
                             @Nullable
                             java.lang.String version,
                             @Nullable
                             java.net.URL location)
    • Method Detail

      • create

        public static MavenArtifact create​(@Nonnull
                                           java.lang.String groupId,
                                           @Nonnull
                                           java.lang.String artifactId,
                                           @Nullable
                                           java.lang.String version,
                                           @Nullable
                                           java.net.URL location)
      • create

        public static MavenArtifact create​(@Nonnull
                                           java.lang.String groupId,
                                           @Nonnull
                                           java.lang.String artifactId,
                                           @Nullable
                                           java.lang.String version)
      • create

        public static MavenArtifact create​(@Nonnull
                                           java.lang.String groupId,
                                           @Nonnull
                                           java.lang.String artifactId)
      • getGroupId

        @Nonnull
        public java.lang.String getGroupId()
        Get the group id of Maven Artifact
        Returns:
        non-null
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class Artifact
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Artifact