Package org.apache.sling.feature
Class Artifact
- java.lang.Object
-
- org.apache.sling.feature.Artifact
-
- All Implemented Interfaces:
Serializable,Comparable<Artifact>
public class Artifact extends Object implements Comparable<Artifact>, Serializable
An artifact consists of- An id
- metadata
- optional alias and start order properties (which are part of the metadata)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_ALIASCan be used in artifact metadata to specify an alias.static StringKEY_FEATURE_ORIGINSstatic StringKEY_START_ORDERThis key might be used by bundles to define the start order.
-
Constructor Summary
Constructors Constructor Description Artifact(jakarta.json.JsonValue json)Construct a new artifactArtifact(ArtifactId id)Construct a new artifact
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Artifact o)Artifactcopy(ArtifactId id)Create a copy of the artifact with a different idbooleanequals(Object obj)Set<ArtifactId>getAliases(boolean includeMain)Obtain the alias or aliases for the artifact.ArtifactId[]getFeatureOrigins()Get the feature origins - if recordedArtifactId[]getFeatureOrigins(ArtifactId self)Get the feature origins If no origins are recorded, the provided artifact id is returnedArtifactIdgetId()Get the id of the artifact.Map<String,String>getMetadata()Get the metadata of the artifact.intgetStartOrder()Get the start order of the artifact.inthashCode()voidsetFeatureOrigins(ArtifactId... featureOrigins)Set the feature originsvoidsetStartOrder(int startOrder)Set the start order of the artifact This is a convenience method which sets the value of the property named#KEY_START_ORDERfrom the metadata.StringtoString()
-
-
-
Field Detail
-
KEY_ALIAS
public static final String KEY_ALIAS
Can be used in artifact metadata to specify an alias. Multiple aliases can be comma-separated.- See Also:
- Constant Field Values
-
KEY_START_ORDER
public static final String KEY_START_ORDER
This key might be used by bundles to define the start order.- See Also:
- Constant Field Values
-
KEY_FEATURE_ORIGINS
public static final String KEY_FEATURE_ORIGINS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Artifact
public Artifact(ArtifactId id)
Construct a new artifact- Parameters:
id- The id of the artifact.- Throws:
IllegalArgumentException- If id isnull.
-
Artifact
public Artifact(jakarta.json.JsonValue json)
Construct a new artifact- Parameters:
json- The json for the artifact- Throws:
IllegalArgumentException- If json isnullor wrongly formatted.- Since:
- 1.4
-
-
Method Detail
-
getId
public ArtifactId getId()
Get the id of the artifact.- Returns:
- The id.
-
getMetadata
public Map<String,String> getMetadata()
Get the metadata of the artifact. The metadata can be modified.- Returns:
- The metadata.
-
getAliases
public Set<ArtifactId> getAliases(boolean includeMain)
Obtain the alias or aliases for the artifact.- Parameters:
includeMain- Whether to include the main ID in the result.- Returns:
- The aliases or an empty set if there are none.
-
getStartOrder
public int getStartOrder()
Get the start order of the artifact. This is a convenience method which gets the value for the property named#KEY_START_ORDERfrom the metadata.- Returns:
- The start order, if no start order is defined,
0is returned. - Throws:
NumberFormatException- If the stored metadata is not a numberIllegalStateException- If the stored metadata is a negative number
-
setStartOrder
public void setStartOrder(int startOrder)
Set the start order of the artifact This is a convenience method which sets the value of the property named#KEY_START_ORDERfrom the metadata.- Parameters:
startOrder- The start order- Throws:
IllegalArgumentException- If the number is negative
-
getFeatureOrigins
public ArtifactId[] getFeatureOrigins()
Get the feature origins - if recorded- Returns:
- A array of feature artifact ids - array might be empty
- Throws:
IllegalArgumentException- If the stored values are not valid artifact ids
-
getFeatureOrigins
public ArtifactId[] getFeatureOrigins(ArtifactId self)
Get the feature origins If no origins are recorded, the provided artifact id is returned- Parameters:
self- The id of the current feature- Returns:
- An array of feature artifact ids
- Throws:
IllegalArgumentException- If the stored values are not valid artifact ids- Since:
- 1.7.0
-
setFeatureOrigins
public void setFeatureOrigins(ArtifactId... featureOrigins)
Set the feature origins- Parameters:
featureOrigins- the array of artifact ids or null to remove the info from this object
-
compareTo
public int compareTo(Artifact o)
- Specified by:
compareToin interfaceComparable<Artifact>
-
copy
public Artifact copy(ArtifactId id)
Create a copy of the artifact with a different id- Parameters:
id- The new id- Returns:
- The copy of the feature with the new id
-
-