Class PolicyVersions<P>

  • Type Parameters:
    P - policy type (or any other type of data corresponding to a specific policy version)
    All Implemented Interfaces:
    Iterable<Map.Entry<org.ow2.authzforce.core.pdp.api.policy.PolicyVersion,​P>>

    public final class PolicyVersions<P>
    extends Object
    implements Iterable<Map.Entry<org.ow2.authzforce.core.pdp.api.policy.PolicyVersion,​P>>
    Policy versions sorted from the latest version to the oldest.

    The choice to have the latest version in first position is motivated by ยง5.10 of XACML core spec: "In the case that more than one matching version can be obtained, then the most recent one SHOULD be used."

    Version:
    $Id: $
    • Constructor Detail

      • PolicyVersions

        public PolicyVersions​(Map<org.ow2.authzforce.core.pdp.api.policy.PolicyVersion,​P> versions)
        Creates instance
        Parameters:
        versions - policy versions
    • Method Detail

      • get

        public P get​(org.ow2.authzforce.core.pdp.api.policy.PolicyVersion version)
        Get policy in a specific version
        Parameters:
        version - policy version
        Returns:
        policy
      • getLatest

        public Map.Entry<org.ow2.authzforce.core.pdp.api.policy.PolicyVersion,​P> getLatest​(Optional<org.ow2.authzforce.core.pdp.api.policy.PolicyVersionPatterns> PolicyVersionPatterns)
        Get the latest policy version matching specific version patterns
        Parameters:
        PolicyVersionPatterns - version patterns
        Returns:
        latest version; null if none matched
      • size

        public int size()
        Get number of versions
        Returns:
        number of policy versions
      • oldestToLatestIterator

        public com.google.common.collect.UnmodifiableIterator<Map.Entry<org.ow2.authzforce.core.pdp.api.policy.PolicyVersion,​P>> oldestToLatestIterator()
        Get iterator over versions from oldest to latest
        Returns:
        unmodifiable iterator over versions from oldest to latest
      • latestToOldestSet

        public NavigableSet<org.ow2.authzforce.core.pdp.api.policy.PolicyVersion> latestToOldestSet()
        Get versions from latest to oldest
        Returns:
        versions from latest to oldest