Package org.apache.sling.feature
Class ArtifactId
java.lang.Object
org.apache.sling.feature.ArtifactId
- All Implemented Interfaces:
Serializable
,Comparable<ArtifactId>
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default type ifnull
is provided as a type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchangeClassifier
(String newClassifier) Provide artifact id with a different classifier.changeType
(String newType) Provide artifact id with a different type.changeVersion
(String newVersion) Provide artifact id with a different version.int
boolean
static ArtifactId
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 ] ] ] ]Return the artifact id.Return the optional classifier.Return the group id.org.osgi.framework.Version
Return the OSGi versiongetType()
Return the type.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
Create a new artifact id from a string, the string must either be a mvn url or a mvn id (= coordinates)toMvnId()
Return a mvn idCreate a Maven like repository nameCreate a Maven like relative repository path.toMvnUrl()
Return a mvn urltoString()
-
Field Details
-
DEFAULT_TYPE
The default type ifnull
is provided as a type. @since 1.3- See Also:
-
-
Constructor Details
-
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 Details
-
parse
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
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
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
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
Return a mvn url- Returns:
- A mvn url
- See Also:
-
toMvnId
Return a mvn id- Returns:
- The mvn id
#see
fromMvnId(String)
-
getGroupId
Return the group id.- Returns:
- The group id.
-
getArtifactId
Return the artifact id.- Returns:
- The artifact id.
-
getClassifier
Return the optional classifier.- Returns:
- The classifier or
null
.
-
getType
Return the type.- Returns:
- The type.
-
getVersion
Return the version.- Returns:
- The version.
-
isSame
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
Create a Maven like relative repository path.- Returns:
- A relative repository path. The path does not start with a slash.
-
toMvnName
Create a Maven like repository name- Returns:
- Just the name of the artifact (including version, classifier, type)
- Since:
- 1.2
-
changeVersion
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
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
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
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ArtifactId>
-
toString
-