Package org.apache.sling.feature
Class Artifact
java.lang.Object
org.apache.sling.feature.Artifact
- All Implemented Interfaces:
Serializable
,Comparable<Artifact>
An artifact consists of
- An id
- metadata
- optional alias and start order properties (which are part of the metadata)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionArtifact
(jakarta.json.JsonValue json) Construct a new artifactArtifact
(ArtifactId id) Construct a new artifact -
Method Summary
Modifier and TypeMethodDescriptionint
copy
(ArtifactId id) Create a copy of the artifact with a different idboolean
getAliases
(boolean includeMain) Obtain the alias or aliases for the artifact.Get the feature origins - if recordedgetFeatureOrigins
(ArtifactId self) Get the feature origins If no origins are recorded, the provided artifact id is returnedgetId()
Get the id of the artifact.Get the metadata of the artifact.int
Get the start order of the artifact.int
hashCode()
void
setFeatureOrigins
(ArtifactId... featureOrigins) Set the feature originsvoid
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_ORDER
from the metadata.toString()
-
Field Details
-
KEY_ALIAS
Can be used in artifact metadata to specify an alias. Multiple aliases can be comma-separated.- See Also:
-
KEY_START_ORDER
This key might be used by bundles to define the start order.- See Also:
-
KEY_FEATURE_ORIGINS
- See Also:
-
-
Constructor Details
-
Artifact
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 isnull
or wrongly formatted.- Since:
- 1.4
-
-
Method Details
-
getId
Get the id of the artifact.- Returns:
- The id.
-
getMetadata
Get the metadata of the artifact. The metadata can be modified.- Returns:
- The metadata.
-
getAliases
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_ORDER
from the metadata.- Returns:
- The start order, if no start order is defined,
0
is 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_ORDER
from the metadata.- Parameters:
startOrder
- The start order- Throws:
IllegalArgumentException
- If the number is negative
-
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
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
Set the feature origins- Parameters:
featureOrigins
- the array of artifact ids or null to remove the info from this object
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Artifact>
-
hashCode
public int hashCode() -
equals
-
copy
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
-
toString
-