Package org.apache.sling.feature
Class ArtifactId
- java.lang.Object
-
- org.apache.sling.feature.ArtifactId
-
- All Implemented Interfaces:
Serializable
,Comparable<ArtifactId>
public class ArtifactId extends Object implements Comparable<ArtifactId>, Serializable
An artifact identifier. An artifact is described by it's Apache Maven coordinates consisting of group id, artifact id, and version. In addition, the classifier and type can be specified. If no type is specified,jar
is assumed. This class is thread-safe.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_TYPE
The default type ifnull
is provided as a type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ArtifactId
changeClassifier(String newClassifier)
Provide artifact id with a different classifier.ArtifactId
changeType(String newType)
Provide artifact id with a different type.ArtifactId
changeVersion(String newVersion)
Provide artifact id with a different version.int
compareTo(ArtifactId o)
boolean
equals(Object o)
static ArtifactId
fromMvnId(String coordinates)
Create a new artifact id from maven coordinates/id groupId:artifactId[:packaging[:classifier]]:versionstatic ArtifactId
fromMvnPath(String path)
Create a new artifact id from a maven path The schema isgroupIdPath/artifactId/version/artifactId-version[-classifier].type
static ArtifactId
fromMvnUrl(String url)
Create a new artifact id from a maven url, 'mvn:' group-id '/' artifact-id [ '/' [version] [ '/' [type] [ '/' classifier ] ] ] ]String
getArtifactId()
Return the artifact id.String
getClassifier()
Return the optional classifier.String
getGroupId()
Return the group id.org.osgi.framework.Version
getOSGiVersion()
Return the OSGi versionString
getType()
Return the type.String
getVersion()
Return the version.int
hashCode()
boolean
isSame(ArtifactId id)
Test whether the artifact id is pointing to the same artifact but potentially a different versionstatic ArtifactId
parse(String s)
Create a new artifact id from a string, the string must either be a mvn url or a mvn id (= coordinates)String
toMvnId()
Return a mvn idString
toMvnName()
Create a Maven like repository nameString
toMvnPath()
Create a Maven like relative repository path.String
toMvnUrl()
Return a mvn urlString
toString()
-
-
-
Field Detail
-
DEFAULT_TYPE
public static final String DEFAULT_TYPE
The default type ifnull
is provided as a type. @since 1.3- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ArtifactId
public ArtifactId(String groupId, String artifactId, String version, String classifier, String type)
Create a new artifact object- Parameters:
groupId
- The group id (required)artifactId
- The artifact id (required)version
- The version (required)classifier
- The classifier (optional)type
- The type/extension (optional, defaults to#DEFAULT_TYPE
.- Throws:
IllegalArgumentException
- If group id, artifact id or version arenull
.
-
-
Method Detail
-
parse
public static ArtifactId parse(String s)
Create a new artifact id from a string, the string must either be a mvn url or a mvn id (= coordinates)- Parameters:
s
- The string to parse- Returns:
- The artifact id
- Throws:
IllegalArgumentException
- if the string can't be parsed to a valid artifact id.
-
fromMvnUrl
public static ArtifactId fromMvnUrl(String url)
Create a new artifact id from a maven url, 'mvn:' group-id '/' artifact-id [ '/' [version] [ '/' [type] [ '/' classifier ] ] ] ]- Parameters:
url
- The url- Returns:
- A new artifact id
- Throws:
IllegalArgumentException
- If the url is not valid
-
fromMvnId
public static ArtifactId fromMvnId(String coordinates)
Create a new artifact id from maven coordinates/id groupId:artifactId[:packaging[:classifier]]:version- Parameters:
coordinates
- The coordinates as outlined above- Returns:
- A new artifact id
- Throws:
IllegalArgumentException
- If the id is not valid
-
fromMvnPath
public static ArtifactId fromMvnPath(String path)
Create a new artifact id from a maven path The schema isgroupIdPath/artifactId/version/artifactId-version[-classifier].type
- Parameters:
path
- The maven path- Returns:
- A new artifact id
- Throws:
IllegalArgumentException
- If the path is not valid- Since:
- 1.3.0
-
toMvnUrl
public String toMvnUrl()
Return a mvn url- Returns:
- A mvn url
- See Also:
fromMvnUrl(String)
-
toMvnId
public String toMvnId()
Return a mvn id- Returns:
- The mvn id
#see
fromMvnId(String)
-
getGroupId
public String getGroupId()
Return the group id.- Returns:
- The group id.
-
getArtifactId
public String getArtifactId()
Return the artifact id.- Returns:
- The artifact id.
-
getClassifier
public String getClassifier()
Return the optional classifier.- Returns:
- The classifier or
null
.
-
getType
public String getType()
Return the type.- Returns:
- The type.
-
getVersion
public String getVersion()
Return the version.- Returns:
- The version.
-
isSame
public boolean isSame(ArtifactId id)
Test whether the artifact id is pointing to the same artifact but potentially a different version- Parameters:
id
- The artifact id- Returns:
true
if group id, artifact id, type and classifier equal
-
getOSGiVersion
public org.osgi.framework.Version getOSGiVersion()
Return the OSGi version- Returns:
- The OSGi version
- Throws:
IllegalArgumentException
- If the numerical components are negative or the qualifier string is invalid.
-
toMvnPath
public String toMvnPath()
Create a Maven like relative repository path.- Returns:
- A relative repository path. The path does not start with a slash.
-
toMvnName
public String toMvnName()
Create a Maven like repository name- Returns:
- Just the name of the artifact (including version, classifier, type)
- Since:
- 1.2
-
changeVersion
public ArtifactId changeVersion(String newVersion)
Provide artifact id with a different version.- Parameters:
newVersion
- The new version- Returns:
- New artifact id based on this id with just a different version.
- Throws:
IllegalArgumentException
- if the version isnull
- Since:
- 1.3
-
changeType
public ArtifactId changeType(String newType)
Provide artifact id with a different type.- Parameters:
newType
- The new type, ifnull
the default#DEFAULT_TYPE
is used- Returns:
- New artifact id based on this id with just a different type.
- Since:
- 1.3
-
changeClassifier
public ArtifactId changeClassifier(String newClassifier)
Provide artifact id with a different classifier.- Parameters:
newClassifier
- The new classifier- Returns:
- New artifact id based on this id with just a different classifier.
- Since:
- 1.3
-
compareTo
public int compareTo(ArtifactId o)
- Specified by:
compareTo
in interfaceComparable<ArtifactId>
-
-