Class Artifact

  • Direct Known Subclasses:
    MavenArtifact

    @Immutable
    public class Artifact
    extends java.lang.Object
    Represents a software artifact with attributes such as artifact ID, version, and location. This class is used to identify and match artifacts based on their properties.

    Example Usage

    
     // Create an artifact with ID and default version (UNKNOWN)
     Artifact artifact1 = Artifact.create("my-artifact");
    
     // Create an artifact with ID and specific version
     Artifact artifact2 = Artifact.create("my-artifact", "1.0.0");
    
     // Create an artifact with ID, version, and location
     URL location = new URL("http://example.com/artifact.jar");
     Artifact artifact3 = Artifact.create("my-artifact", "1.0.0", location);
    
     // Matching artifacts based on ID and version
     boolean isMatch = artifact1.matches(artifact2); // returns false
     
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String UNKNOWN  
      static java.lang.String WILDCARD  
    • Constructor Summary

      Constructors 
      Constructor Description
      Artifact​(java.lang.String artifactId, java.lang.String version, java.net.URL location)  
    • Constructor Detail

      • Artifact

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

      • create

        public static Artifact create​(@Nonnull
                                      java.lang.String artifactId)
      • getArtifactId

        @Nonnull
        public java.lang.String getArtifactId()
        Get the artifact Id
        Returns:
        non-null
      • getVersion

        @Nullable
        public java.lang.String getVersion()
        Get the version
        Returns:
        nullable
      • getLocation

        @Nullable
        public java.net.URL getLocation()
        Get the location of artifact resource
        Returns:
        nullable
      • matches

        public boolean matches​(Artifact artifact)
      • matchesArtifactId

        protected boolean matchesArtifactId​(Artifact artifact)
      • matchesVersion

        protected boolean matchesVersion​(Artifact artifact)
      • matches

        protected boolean matches​(Artifact artifact,
                                  java.util.function.Function<Artifact,​java.lang.String> getterFunction)
      • equals

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

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