Class 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 Detail

    • Constructor Detail

      • ArtifactRules

        public ArtifactRules()
        Create a new rules object
    • 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 null if the extension is null.
        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 feature
        rules - The rules. If null the extension will be removed.
        Throws:
        IllegalStateException - If the feature has already an extension of a wrong type
        IllegalArgumentException - If the rules can't be serialized to JSON
      • fromJSONObject

        public void fromJSONObject​(jakarta.json.JsonObject jsonObj)
                            throws IOException
        Extract the metadata from the JSON object. This method first calls clear().
        Overrides:
        fromJSONObject in class AttributeableEntity
        Parameters:
        jsonObj - The JSON Object
        Throws:
        IOException - If JSON parsing fails
      • getMode

        public Mode getMode()
        Get the validation mode. The default is Mode.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.