public final class DotName extends java.lang.Object implements java.lang.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 | Class and Description |
---|---|
private static class |
DotName.IndexState |
Modifier and Type | Field and Description |
---|---|
private boolean |
componentized |
private int |
hash |
private boolean |
innerClass |
(package private) static DotName |
JAVA_LANG_NAME |
(package private) static DotName |
JAVA_NAME |
private java.lang.String |
local |
(package private) static DotName |
OBJECT_NAME |
private DotName |
prefix |
Constructor and Description |
---|
DotName(DotName prefix,
java.lang.String local,
boolean noDots,
boolean innerClass) |
Modifier and Type | Method and Description |
---|---|
private void |
buildString(char delim,
java.lang.StringBuilder builder) |
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,
java.lang.String localName)
Constructs a componentized DotName.
|
static DotName |
createComponentized(DotName prefix,
java.lang.String localName,
boolean innerClass)
Constructs a componentized DotName.
|
static DotName |
createSimple(java.lang.String name)
Constructs a simple DotName which stores the string in it's entirety.
|
private static boolean |
crossEquals(DotName simple,
DotName comp) |
boolean |
equals(java.lang.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 a componentized DotName is separated
by an inner class style delimiter ('$").
|
java.lang.String |
local()
Returns the local portion of this DotName.
|
private int |
nextChar(DotName.IndexState state,
DotName name) |
DotName |
prefix()
Returns the parent prefix for this DotName or null if there is none.
|
private void |
stripPackage(java.lang.StringBuilder builder) |
java.lang.String |
toString()
Returns the regular fully qualifier class name.
|
java.lang.String |
toString(char delim) |
java.lang.String |
withoutPackagePrefix()
Returns the portion of this DotName that does not contain a package prefix.
|
static final DotName JAVA_NAME
static final DotName JAVA_LANG_NAME
static final DotName OBJECT_NAME
private final DotName prefix
private final java.lang.String local
private int hash
private final boolean componentized
private final boolean innerClass
DotName(DotName prefix, java.lang.String local, boolean noDots, boolean innerClass)
public static DotName createSimple(java.lang.String name)
name
- A fully qualified non-null name (with dots)public static DotName createComponentized(DotName prefix, java.lang.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, java.lang.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 style name, requiring '$' vs '.'public DotName prefix()
public java.lang.String local()
Use withoutPackagePrefix()
instead of this method if the
desired value is simply the right most portion (including dollar signs if
present) after a '.' delimiter.
public java.lang.String withoutPackagePrefix()
private void stripPackage(java.lang.StringBuilder builder)
public boolean isComponentized()
public boolean isInner()
index.get(name).nestingType() !+ TOP_LEVEL;
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(char delim)
private void buildString(char delim, java.lang.StringBuilder builder)
public int hashCode()
DotName
.
Whether or not a DotName
is componentized has no impact on the calculated hash code.hashCode
in class java.lang.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 java.lang.Comparable<DotName>
other
- the DotName to compare toComparable.compareTo(Object)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the DotName object to compare toObject.equals(Object)
private int nextChar(DotName.IndexState state, DotName name)