Class Scope

    • Constructor Detail

      • Scope

        public Scope​(String scopeStr)
        Create a new scope.
        Parameters:
        scopeStr - a space delimited scope string.
      • Scope

        public Scope​(Set<String> scopeSet)
        Create a new scope.
        Parameters:
        scopeSet - a set of scope strings.
      • Scope

        public Scope​(String... scopeArray)
        Create a new scope.
        Parameters:
        scopeArray - scope strings.
    • Method Detail

      • getScope

        public static Scope getScope​(String scopeStr)
        Obtain a Scope representing the specified space delimited scope string.

        If the specified space delimited scope string represents a configured Default Scope, Common or Exclusive Scope, Common or Exclusive Scope Group, or a Common or Exclusive Dynamic Scope object, a cached scope object will be returned. Otherwise, a new Scope will be created and returned.

        Parameters:
        scopeStr - a space delimited scope string.
        Returns:
        a Scope representing the specified space delimited scope string.
      • getScopeStr

        public String getScopeStr()
        Get the list of scopes.
        Returns:
        a space delimited string of scopes.
      • toString

        public String toString()
        Get the string of scopes.
        Overrides:
        toString in class Object
        Returns:
        a space delimited string of scopes.
      • getScopeSet

        public Set<String> getScopeSet()
        Get the set of scopes.
        Returns:
        a set of scopes.
      • hasScope

        public boolean hasScope​(String individualScopeValue)
        Determines if the current set of scopes contains the specified scope.
        Parameters:
        individualScopeValue - the scope to search for.
        Returns:
        true if this scope contains the specified scope, false otherwise.
      • equals

        public boolean equals​(Object obj)
        Determines if two scope objects contain the same list of scopes.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Returns the object's hashcode
        Overrides:
        hashCode in class Object
        Returns:
        the object's hashcode
      • isEqualOrLesserThan

        public boolean isEqualOrLesserThan​(Scope scope)
        Determines if the scope object contains the same scopes, or less, than the one passed in.
        Parameters:
        scope - the scope to compare.
        Returns:
        true if the scope object contains the same, or fewer, scopes than the one passed in.
      • hasAllScopes

        public boolean hasAllScopes​(Scope scope)
        A Scope object contains a set of scopes. This method determines if the set of scopes within the current Scope object contains all scopes passed in with the 'other' Scope object.
        Parameters:
        scope - : the set of scopes within the Scope object to search for.
        Returns:
        true if the set of scopes within the Scope object contains all scopes passed in, false otherwise.
      • scopesNotIn

        public Set<String> scopesNotIn​(Scope scope)
        Returns the difference between the current scope and the scope passed in. e.g. current scope: { a, b, c }. passed in scope: { b, c }. Returns: a
        Parameters:
        scope - the scope to compare differences.
        Returns:
        Returns the difference between the current scope and the scope passed in.
      • expanded

        public Scope expanded()
        Expands all group mappings by iterating the scopes. If a group contains that scope, all scopes in that group are added to the list of scopes to be returned.

        e.g. a scope contains scopes = { a, b, c } and group a = { d, e } and group b = { a, f } then this will return a new scope containing scopes { a, b, c, d, e, f }

        Returns:
        a new scope containing just scopes with all group mappings expanded.
      • decode

        public static Set<String> decode​(String scope)
        Converts a space delimited string of scopes to a set.
        Parameters:
        scope - space delimited string of scopes.
        Returns:
        set of scopes.
      • encode

        public static String encode​(Set<String> scopes)
        Converts a set of scopes to a space delimited string of scopes.
        Parameters:
        scopes - a set of scopes.
        Returns:
        a space delimited string of scopes.