Class ArtifactRules
- java.lang.Object
-
- org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
-
- org.apache.sling.feature.extension.apiregions.api.artifacts.ArtifactRules
-
public class ArtifactRules extends AttributeableEntity
Artifact rules define additional rules for artifacts in a feature model. The rules are stored as an extension in the feature model. This class is not thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXTENSION_NAMEThe name of the feature model extension.
-
Constructor Summary
Constructors Constructor Description ArtifactRules()Create a new rules object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear the object and reset to defaultsjakarta.json.JsonObjectBuildercreateJson()Convert this object into JSONvoidfromJSONObject(jakarta.json.JsonObject jsonObj)Extract the metadata from the JSON object.static ArtifactRulesgetArtifactRules(org.apache.sling.feature.Extension ext)Get the artifact rules from the extension - if it exists.static ArtifactRulesgetArtifactRules(org.apache.sling.feature.Feature feature)Get the artifact rules from the feature - if it exists.List<VersionRule>getArtifactVersionRules()Return the list of version rules for artifacts.List<VersionRule>getBundleVersionRules()Return the list of version rules for bundles.ModegetMode()Get the validation mode.static voidsetArtifactRules(org.apache.sling.feature.Feature feature, ArtifactRules rules)Set the rules as an extension to the featureprotected voidsetDefaults()Apply the non-null default values.voidsetMode(Mode value)Set the validation mode-
Methods inherited from class org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
getAttributes, getBoolean, getInteger, getNumber, getString, getString, getStringArray, setString, setStringArray, toJSONObject
-
-
-
-
Field Detail
-
EXTENSION_NAME
public static final String EXTENSION_NAME
The name of the feature model extension.- See Also:
- Constant Field Values
-
-
Method Detail
-
getArtifactRules
public static ArtifactRules getArtifactRules(org.apache.sling.feature.Feature feature)
Get the artifact rules from the feature - if it exists. If the rules are updated, the containing feature is left untouched.setArtifactRules(Feature, ArtifactRules)can be used to update the feature.- Parameters:
feature- The feature- Returns:
- The rules or
null. - Throws:
IllegalArgumentException- If the extension is wrongly formatted
-
getArtifactRules
public static ArtifactRules getArtifactRules(org.apache.sling.feature.Extension ext)
Get the artifact rules from the extension - if it exists. If the rules are updated, the containing feature is left untouched.setArtifactRules(Feature, ArtifactRules)can be used to update the feature.- Parameters:
ext- The extension- Returns:
- The rules or
nullif the extension isnull. - Throws:
IllegalArgumentException- If the extension is wrongly formatted
-
setArtifactRules
public static void setArtifactRules(org.apache.sling.feature.Feature feature, ArtifactRules rules)Set the rules as an extension to the feature- Parameters:
feature- The featurerules- The rules. Ifnullthe extension will be removed.- Throws:
IllegalStateException- If the feature has already an extension of a wrong typeIllegalArgumentException- If the rules can't be serialized to JSON
-
setDefaults
protected void setDefaults()
Description copied from class:AttributeableEntityApply the non-null default values.- Overrides:
setDefaultsin classAttributeableEntity
-
clear
public void clear()
Clear the object and reset to defaults- Overrides:
clearin classAttributeableEntity
-
createJson
public jakarta.json.JsonObjectBuilder createJson() throws IOExceptionConvert this object into JSON- Overrides:
createJsonin classAttributeableEntity- Returns:
- The json object builder
- Throws:
IOException- If generating the JSON fails
-
fromJSONObject
public void fromJSONObject(jakarta.json.JsonObject jsonObj) throws IOExceptionExtract the metadata from the JSON object. This method first callsclear().- Overrides:
fromJSONObjectin classAttributeableEntity- Parameters:
jsonObj- The JSON Object- Throws:
IOException- If JSON parsing fails
-
getMode
public Mode getMode()
Get the validation mode. The default isMode.STRICT- Returns:
- The mode
-
setMode
public void setMode(Mode value)
Set the validation mode- Parameters:
value- The validation mode
-
getBundleVersionRules
public List<VersionRule> getBundleVersionRules()
Return the list of version rules for bundles. The returned list is mutable.- Returns:
- The list of rules, might be empty.
-
getArtifactVersionRules
public List<VersionRule> getArtifactVersionRules()
Return the list of version rules for artifacts. The returned list is mutable.- Returns:
- the list of rules, might be empty.
-
-