Package io.microsphere.classloading
Class Artifact
- java.lang.Object
-
- io.microsphere.classloading.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
-
-
Constructor Summary
Constructors Constructor Description Artifact(java.lang.String artifactId, java.lang.String version, java.net.URL location)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Artifact
create(java.lang.String artifactId)
static Artifact
create(java.lang.String artifactId, java.lang.String version)
static Artifact
create(java.lang.String artifactId, java.lang.String version, java.net.URL location)
boolean
equals(java.lang.Object o)
java.lang.String
getArtifactId()
Get the artifact Idjava.net.URL
getLocation()
Get the location of artifact resourcejava.lang.String
getVersion()
Get the versionint
hashCode()
boolean
matches(Artifact artifact)
protected boolean
matches(Artifact artifact, java.util.function.Function<Artifact,java.lang.String> getterFunction)
protected boolean
matchesArtifactId(Artifact artifact)
protected boolean
matchesVersion(Artifact artifact)
java.lang.String
toString()
-
-
-
Field Detail
-
WILDCARD
public static final java.lang.String WILDCARD
- See Also:
- Constant Field Values
-
UNKNOWN
public static final java.lang.String UNKNOWN
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static Artifact create(@Nonnull java.lang.String artifactId, @Nullable java.lang.String version, @Nullable java.net.URL location)
-
create
public static Artifact create(@Nonnull java.lang.String artifactId, @Nullable java.lang.String version)
-
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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-