Class VersionRule


  • public class VersionRule
    extends AttributeableEntity
    A rule to validate the version of an artifact. This class is not thread safe.
    • Constructor Detail

      • VersionRule

        public VersionRule()
        Create a new rules object
    • Method Detail

      • 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
      • getArtifactId

        public org.apache.sling.feature.ArtifactId getArtifactId()
        Get the artifact id
        Returns:
        the artifactId
      • setArtifactId

        public void setArtifactId​(org.apache.sling.feature.ArtifactId artifactId)
        Set the artifact id
        Parameters:
        artifactId - the artifactId to set
      • getMessage

        public String getMessage()
        The validation message
        Returns:
        the message
      • setMessage

        public void setMessage​(String message)
        Set the validation message
        Parameters:
        message - the message to set
      • getAllowedVersionRanges

        public org.osgi.framework.VersionRange[] getAllowedVersionRanges()
        The allowed version ranges
        Returns:
        the allowedVersions or null
      • setAllowedVersionRanges

        public void setAllowedVersionRanges​(org.osgi.framework.VersionRange[] allowedVersions)
        Set the allowed version ranges
        Parameters:
        allowedVersions - the allowedVersions to set
      • getDeniedVersionRanges

        public org.osgi.framework.VersionRange[] getDeniedVersionRanges()
        Get the denied version ranges
        Returns:
        the deniedVersions or null
      • setDeniedVersionRanges

        public void setDeniedVersionRanges​(org.osgi.framework.VersionRange[] deniedVersions)
        Set the denied version ranges
        Parameters:
        deniedVersions - the deniedVersions to set
      • isAllowed

        public boolean isAllowed​(org.osgi.framework.Version artifactVersion)
        Check if a version is allowed according to the rules
        Parameters:
        artifactVersion - The version
        Returns:
        true if it is allowed, false otherwise