Package org.apache.sling.feature
Class ArtifactId
- java.lang.Object
-
- org.apache.sling.feature.ArtifactId
-
- All Implemented Interfaces:
Comparable<ArtifactId>
public class ArtifactId extends Object implements 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,jaris assumed. This class is not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_TYPEThe default type ifnullis provided as a type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ArtifactIdchangeClassifier(String newClassifier)Provide artifact id with a different classifier.ArtifactIdchangeType(String newType)Provide artifact id with a different type.ArtifactIdchangeVersion(String newVersion)Provide artifact id with a different version.intcompareTo(ArtifactId o)booleanequals(Object o)static ArtifactIdfromMvnId(String coordinates)Create a new artifact id from maven coordinates/id groupId:artifactId[:packaging[:classifier]]:versionstatic ArtifactIdfromMvnPath(String path)Create a new artifact id from a maven path The schema isgroupIdPath/artifactId/version/artifactId-version[-classifier].typestatic ArtifactIdfromMvnUrl(String url)Create a new artifact id from a maven url, 'mvn:' group-id '/' artifact-id [ '/' [version] [ '/' [type] [ '/' classifier ] ] ] ]StringgetArtifactId()Return the artifact id.StringgetClassifier()Return the optional classifier.StringgetGroupId()Return the group id.org.osgi.framework.VersiongetOSGiVersion()Return the OSGi versionStringgetType()Return the type.StringgetVersion()Return the version.inthashCode()booleanisSame(ArtifactId id)Test whether the artifact id is pointing to the same artifact but potentially a different versionstatic ArtifactIdparse(String s)Create a new artifact id from a string, the string must either be a mvn url or a mvn id (= coordinates)StringtoMvnId()Return a mvn idStringtoMvnName()Create a Maven like repository nameStringtoMvnPath()Create a Maven like relative repository path.StringtoMvnUrl()Return a mvn urlStringtoString()
-
-
-
Field Detail
-
DEFAULT_TYPE
public static final String DEFAULT_TYPE
The default type ifnullis 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:
trueif 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, ifnullthe default#DEFAULT_TYPEis 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:
compareToin interfaceComparable<ArtifactId>
-
-