Package org.eclipse.aether.util.artifact
Class DelegatingArtifact
- java.lang.Object
-
- org.eclipse.aether.artifact.AbstractArtifact
-
- org.eclipse.aether.util.artifact.DelegatingArtifact
-
- All Implemented Interfaces:
Artifact
public abstract class DelegatingArtifact extends AbstractArtifact
An artifact that delegates to another artifact instance. This class serves as a base for subclasses that want to carry additional data fields.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDelegatingArtifact(Artifact delegate)Creates a new artifact instance that delegates to the specified artifact.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Compares this artifact with the specified object.java.lang.StringgetArtifactId()Gets the artifact identifier of this artifact, for example "maven-model".java.lang.StringgetBaseVersion()Gets the base version of this artifact, for example "1.0-SNAPSHOT".java.lang.StringgetClassifier()Gets the classifier of this artifact, for example "sources".java.lang.StringgetExtension()Gets the (file) extension of this artifact, for example "jar" or "tar.gz".java.io.FilegetFile()Gets the file of this artifact.java.lang.StringgetGroupId()Gets the group identifier of this artifact, for example "org.apache.maven".java.util.Map<java.lang.String,java.lang.String>getProperties()Gets the properties of this artifact.java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)Gets the specified property.java.lang.StringgetVersion()Gets the version of this artifact, for example "1.0-20100529-1213".inthashCode()Returns a hash code for this artifact.booleanisSnapshot()Determines whether this artifact uses a snapshot version.protected abstract DelegatingArtifactnewInstance(Artifact delegate)Creates a new artifact instance that delegates to the specified artifact.ArtifactsetFile(java.io.File file)Sets the file of the artifact.ArtifactsetProperties(java.util.Map<java.lang.String,java.lang.String> properties)Sets the properties for the artifact.ArtifactsetVersion(java.lang.String version)Sets the version of the artifact.java.lang.StringtoString()-
Methods inherited from class org.eclipse.aether.artifact.AbstractArtifact
copyProperties
-
-
-
-
Field Detail
-
delegate
private final Artifact delegate
-
-
Constructor Detail
-
DelegatingArtifact
protected DelegatingArtifact(Artifact delegate)
Creates a new artifact instance that delegates to the specified artifact.- Parameters:
delegate- The artifact to delegate to, must not benull.
-
-
Method Detail
-
newInstance
protected abstract DelegatingArtifact newInstance(Artifact delegate)
Creates a new artifact instance that delegates to the specified artifact. Subclasses should use this hook to instantiate themselves, taking along any data from the current instance that was added.- Parameters:
delegate- The artifact to delegate to, must not benull.- Returns:
- The new delegating artifact, never
null.
-
getGroupId
public java.lang.String getGroupId()
Description copied from interface:ArtifactGets the group identifier of this artifact, for example "org.apache.maven".- Returns:
- The group identifier, never
null.
-
getArtifactId
public java.lang.String getArtifactId()
Description copied from interface:ArtifactGets the artifact identifier of this artifact, for example "maven-model".- Returns:
- The artifact identifier, never
null.
-
getVersion
public java.lang.String getVersion()
Description copied from interface:ArtifactGets the version of this artifact, for example "1.0-20100529-1213". Note that in case of meta versions like "1.0-SNAPSHOT", the artifact's version depends on the state of the artifact. Artifacts that have been resolved or deployed will usually have the meta version expanded.- Returns:
- The version, never
null.
-
setVersion
public Artifact setVersion(java.lang.String version)
Description copied from interface:ArtifactSets the version of the artifact.- Specified by:
setVersionin interfaceArtifact- Overrides:
setVersionin classAbstractArtifact- Parameters:
version- The version of this artifact, may benullor empty.- Returns:
- The new artifact, never
null.
-
getBaseVersion
public java.lang.String getBaseVersion()
Description copied from interface:ArtifactGets the base version of this artifact, for example "1.0-SNAPSHOT". In contrast to theArtifact.getVersion(), the base version will always refer to the unresolved meta version.- Specified by:
getBaseVersionin interfaceArtifact- Overrides:
getBaseVersionin classAbstractArtifact- Returns:
- The base version, never
null.
-
isSnapshot
public boolean isSnapshot()
Description copied from interface:ArtifactDetermines whether this artifact uses a snapshot version.- Specified by:
isSnapshotin interfaceArtifact- Overrides:
isSnapshotin classAbstractArtifact- Returns:
trueif the artifact is a snapshot,falseotherwise.
-
getClassifier
public java.lang.String getClassifier()
Description copied from interface:ArtifactGets the classifier of this artifact, for example "sources".- Returns:
- The classifier or an empty string if none, never
null.
-
getExtension
public java.lang.String getExtension()
Description copied from interface:ArtifactGets the (file) extension of this artifact, for example "jar" or "tar.gz".- Returns:
- The file extension (without leading period), never
null.
-
getFile
public java.io.File getFile()
Description copied from interface:ArtifactGets the file of this artifact. Note that only resolved artifacts have a file associated with them. In general, callers must not assume any relationship between an artifact's filename and its coordinates.- Returns:
- The file or
nullif the artifact isn't resolved.
-
setFile
public Artifact setFile(java.io.File file)
Description copied from interface:ArtifactSets the file of the artifact.- Specified by:
setFilein interfaceArtifact- Overrides:
setFilein classAbstractArtifact- Parameters:
file- The file of the artifact, may benull- Returns:
- The new artifact, never
null.
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)Description copied from interface:ArtifactGets the specified property.- Specified by:
getPropertyin interfaceArtifact- Overrides:
getPropertyin classAbstractArtifact- Parameters:
key- The name of the property, must not benull.defaultValue- The default value to return in case the property is not set, may benull.- Returns:
- The requested property value or
nullif the property is not set and no default value was provided. - See Also:
ArtifactProperties
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Description copied from interface:ArtifactGets the properties of this artifact. Clients may use these properties to associate non-persistent values with an artifact that help later processing when the artifact gets passed around within the application.- Returns:
- The (read-only) properties, never
null. - See Also:
ArtifactProperties
-
setProperties
public Artifact setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Description copied from interface:ArtifactSets the properties for the artifact. Note that these properties exist merely in memory and are not persisted when the artifact gets installed/deployed to a repository.- Specified by:
setPropertiesin interfaceArtifact- Overrides:
setPropertiesin classAbstractArtifact- Parameters:
properties- The properties for the artifact, may benull.- Returns:
- The new artifact, never
null. - See Also:
ArtifactProperties
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:AbstractArtifactCompares this artifact with the specified object.- Overrides:
equalsin classAbstractArtifact- Parameters:
obj- The object to compare this artifact against, may benull.- Returns:
trueif and only if the specified object is anotherArtifactwith equal coordinates, properties and file,falseotherwise.
-
hashCode
public int hashCode()
Description copied from class:AbstractArtifactReturns a hash code for this artifact.- Overrides:
hashCodein classAbstractArtifact- Returns:
- A hash code for the artifact.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractArtifact
-
-