public final class DotName extends Object implements Comparable<DotName>
Both the simple and componentized variants are considered semantically equivalent if they refer to the same logical name. More specifically the equals and hashCode methods return the same values for the same semantic name regardless of the variant used. Which variant to use when depends on the specific performance and overhead objectives of the specific use pattern.
Simple names are cheap to construct (just a an additional wrapper object), so are ideal for temporary use, like looking for an entry in a Map. Componentized names however require that they be split in advance, and so require some additional time to construct. However the memory benefits of reusing component strings make them desirable when stored in a longer term area such as in a Java data structure.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DotName other)
Compares a
DotName to another DotName and returns whether this DotName
is lesser than, greater than, or equal to the specified DotName. |
static DotName |
createComponentized(DotName prefix,
String localName)
Constructs a componentized DotName.
|
static DotName |
createComponentized(DotName prefix,
String localName,
boolean innerClass)
Constructs a componentized DotName.
|
static DotName |
createSimple(String name)
Constructs a simple DotName which stores the string in it's entirety.
|
boolean |
equals(Object o)
Compares a DotName to another DotName and returns true if the represent
the same underlying semantic name.
|
int |
hashCode()
Returns a hash code which is based on the semantic representation of this
DotName . |
boolean |
isComponentized()
Returns whether this DotName is a componentized variant.
|
boolean |
isInner()
Returns whether the local portion of this DotName represents an inner class.
|
String |
local()
Returns the local portion of this DotName.
|
DotName |
prefix()
Returns the parent prefix for this DotName or null if there is none.
|
String |
toString()
Returns the regular fully qualifier class name.
|
String |
toString(char delim) |
public static DotName createSimple(String name)
name
- A fully qualified non-null name (with dots)public static DotName createComponentized(DotName prefix, String localName)
prefix
- Another DotName that is the portion to the left of
localName, this may be null if there is not onelocalName
- the local non-null portion of this name, which does not contain
'.'public static DotName createComponentized(DotName prefix, String localName, boolean innerClass)
prefix
- Another DotName that is the portion to the left of
localName, this may be null if there is not onelocalName
- the local non-null portion of this name, which does not contain
'.'innerClass
- whether or not this localName is an inner class name, requiring '$' vs '.'public DotName prefix()
public String local()
public boolean isComponentized()
public boolean isInner()
public String toString()
public String toString(char delim)
public int hashCode()
DotName
.
Whether or not a DotName
is componentized has no impact on the calculated hash code.hashCode
in class Object
Object.hashCode()
public int compareTo(DotName other)
DotName
to another DotName
and returns whether this DotName
is lesser than, greater than, or equal to the specified DotName. If this DotName
is lesser,
a negative value is returned. If greater, a positive value is returned. If equal, zero is returned.compareTo
in interface Comparable<DotName>
other
- the DotName to compare toComparable.compareTo(Object)
public boolean equals(Object o)
equals
in class Object
o
- the DotName object to compare toObject.equals(Object)
Copyright © 2018 JBoss by Red Hat. All rights reserved.