public final class ClassName extends TypeName implements Comparable<ClassName>
Modifier and Type | Method and Description |
---|---|
static ClassName |
bestGuess(String classNameString)
Returns a new
ClassName instance for the given fully-qualified class name string. |
int |
compareTo(ClassName o) |
ClassName |
enclosingClassName()
Returns the enclosing class, like
Map for Map.Entry . |
boolean |
equals(Object o) |
static ClassName |
get(Class<?> clazz) |
static ClassName |
get(String packageName,
String simpleName,
String... simpleNames)
Returns a class name created from the given parts.
|
static ClassName |
get(TypeElement element)
Returns the class name for
element . |
int |
hashCode() |
ClassName |
nestedClass(String name)
Returns a new
ClassName instance for the specified name as nested inside this
class. |
String |
packageName()
Returns the package name, like
"java.util" for Map.Entry . |
ClassName |
peerClass(String name)
Returns a class that shares the same enclosing package or class.
|
String |
simpleName()
Returns the simple name of this class, like
"Entry" for Map.Entry . |
List<String> |
simpleNames() |
public static final ClassName OBJECT
public String packageName()
"java.util"
for Map.Entry
.public ClassName enclosingClassName()
Map
for Map.Entry
. Returns null if this class
is not nested in another class.public ClassName nestedClass(String name)
ClassName
instance for the specified name
as nested inside this
class.public ClassName peerClass(String name)
enclosingClassName().nestedClass(name)
. Otherwise
it is equivalent to get(packageName(), name)
.public String simpleName()
"Entry"
for Map.Entry
.public static ClassName bestGuess(String classNameString)
ClassName
instance for the given fully-qualified class name string. This
method assumes that the input is ASCII and follows typical Java style (lowercase package
names, UpperCamelCase class names) and may produce incorrect results or throw
IllegalArgumentException
otherwise. For that reason, get(Class)
and
get(Class)
should be preferred as they can correctly create ClassName
instances without such restrictions.public static ClassName get(String packageName, String simpleName, String... simpleNames)
"java.util"
and simple names "Map"
, "Entry"
yields Map.Entry
.public static ClassName get(TypeElement element)
element
.public int compareTo(ClassName o)
compareTo
in interface Comparable<ClassName>
Copyright © 2015 Square, Inc.. All Rights Reserved.