Package org.gcube.common.security
Class ContextBean
java.lang.Object
org.gcube.common.security.ContextBean
A data object model representing a hierarchical scope.
This class provides a structured representation for scopes that are
defined in a linear, path-like syntax (e.g., "/INFRASTRUCTURE/VO/VRE").
It supports three types of scopes: ContextBean.Type.INFRASTRUCTURE, ContextBean.Type.VO,
and ContextBean.Type.VRE. The class allows for navigating the scope hierarchy
and provides utility methods for comparison and string representation.
- Author:
- Fabio Simeoni
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration for the different types of scopes supported. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionContextBean(String scope) Constructs a newContextBeanfrom a linear string representation. -
Method Summary
Modifier and TypeMethodDescriptionReturns the enclosing scope in the hierarchy.booleanCompares this object with another object for equality.inthashCode()Calculates the hash code for this object based on its name, type, and enclosing scope.booleanis(ContextBean.Type type) Checks if the scope has a specificContextBean.Type.name()Returns the name of this scope level.toString()Returns the linear string representation of the scope.type()Returns theContextBean.Typeof this scope.
-
Field Details
-
separator
Separator used in the linear syntax of scopes.
-
-
Constructor Details
-
ContextBean
Constructs a newContextBeanfrom a linear string representation. The constructor parses the string to determine the scope's name, type, and its enclosing scope.- Parameters:
scope- The linear string representing the scope (e.g., "/INFRASTRUCTURE/VO/VRE").- Throws:
IllegalArgumentException- if the provided scope string is malformed or does not conform to the expected hierarchy.
-
-
Method Details
-
name
Returns the name of this scope level.- Returns:
- The name of the scope.
-
is
Checks if the scope has a specificContextBean.Type.- Parameters:
type- TheContextBean.Typeto check against.- Returns:
trueif the scope's type matches the given type, otherwisefalse.
-
type
Returns theContextBean.Typeof this scope.- Returns:
- The type of the scope.
-
enclosingScope
Returns the enclosing scope in the hierarchy.- Returns:
- The parent
ContextBeanobject, ornullif this is a top-level scope (type is INFRASTRUCTURE).
-
toString
Returns the linear string representation of the scope. This method reconstructs the path from the current scope to the top-level. -
hashCode
public int hashCode()Calculates the hash code for this object based on its name, type, and enclosing scope. -
equals
Compares this object with another object for equality.
-