Package org.forgerock.openig.heap
Class Name
- java.lang.Object
-
- org.forgerock.openig.heap.Name
-
public final class Name extends Object
A Name uniquely identify an object within a hierarchy. It is composed of a (possiblenull
parent Name) and a leaf name (nevernull
).Consumers of that API are free to do their own Name rendering (they have access to the whole Name's chain with
getParent()
method) or use the pre-definedgetFullyQualifiedName()
andgetScopedName()
methods. These methods use the plus (+) character as separator.The Name instances are immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Name
child(String name)
Creates a new Name, relative to this Name with the given leaf name.Name
decorated(String decorator)
Returns this name with the last segment adapted to include the decorator name.boolean
equals(Object o)
String
getFullyQualifiedName()
Returns a String representation of this Name that includes the full Name hierarchy.String
getHierarchicalLeaf()
Returns a String representation of this leaf's Name that is compliant with the hierarchical naming, i.e.String
getHierarchicalName()
Returns a String representation of this Name that includes the full Name hierarchy, with each segment name being 'slugged'.String
getLeaf()
Returns the leaf name (cannot benull
).Name
getParent()
Returns the parent Name (can benull
).String
getScopedName()
Returns a String representation of this Name that includes only the first parent and the leaf name.int
hashCode()
static Name
of(Class<?> type)
Builds a new Name for the given type.static Name
of(String... parts)
Builds a new Name using the given name parts.String
toString()
Returns the fully qualified name of this Name (format: (parent '+')* leaf).
-
-
-
Method Detail
-
of
public static Name of(String... parts)
Builds a new Name using the given name parts. They are ordered in descending order (ancestors first, leaf last)- Parameters:
parts
- ordered fragments of the name- Returns:
- a new Name using the given name parts.
-
of
public static Name of(Class<?> type)
Builds a new Name for the given type. The generated name will use the given type's short name as leaf and will have no parent.- Parameters:
type
- typ used to generate a name- Returns:
- a new Name for the given type
-
getParent
public Name getParent()
Returns the parent Name (can benull
).- Returns:
- the parent Name (can be
null
).
-
getLeaf
public String getLeaf()
Returns the leaf name (cannot benull
).- Returns:
- the leaf name.
-
child
public Name child(String name)
Creates a new Name, relative to this Name with the given leaf name.- Parameters:
name
- relative leaf name- Returns:
- a new Name, relative to this Name.
-
decorated
public Name decorated(String decorator)
Returns this name with the last segment adapted to include the decorator name. The last segment is changed to follow this pattern: @decorator[last-segment].- Parameters:
decorator
- decorator name.- Returns:
- a new decorated name based on this name
-
getFullyQualifiedName
public String getFullyQualifiedName()
Returns a String representation of this Name that includes the full Name hierarchy.The following format has to be expected:
(parent '+')* leaf
Examples:
LocalNameOnly
gateway+_Router
gateway+_Router+OAuth2ResourceServerFilter
- Returns:
- a String representation of this Name that includes the full Name hierarchy.
-
getHierarchicalName
public String getHierarchicalName()
Returns a String representation of this Name that includes the full Name hierarchy, with each segment name being 'slugged'.The following format has to be expected:
(parent '.')* slug(leaf)
Examples:
localnameonly
gateway._router
gateway._router.oauth2resourceserverfilter
- Returns:
- a String representation of this Name that includes the full Name hierarchy.
- See Also:
StringUtil.slug(String)
-
getHierarchicalLeaf
public String getHierarchicalLeaf()
Returns a String representation of this leaf's Name that is compliant with the hierarchical naming, i.e. the value being 'slugged'.- Returns:
- a String representation of this Name that includes the full Name hierarchy.
- See Also:
StringUtil.slug(String)
-
getScopedName
public String getScopedName()
Returns a String representation of this Name that includes only the first parent and the leaf name.The following format has to be expected:
(parent '+')? leaf
Examples:
LocalNameOnly
gateway+_Router
- Returns:
- a String representation of this Name that includes only the first parent and the leaf name.
-
toString
public String toString()
Returns the fully qualified name of this Name (format: (parent '+')* leaf).- Overrides:
toString
in classObject
- Returns:
- the fully qualified name of this Name.
- See Also:
getFullyQualifiedName()
-
-