Class ClassName
java.lang.Object
com.squareup.javapoet.TypeName
com.squareup.javapoet.ClassName
- All Implemented Interfaces:
Comparable<ClassName>
A fully-qualified class name for top-level and member classes.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionannotated(List<AnnotationSpec> annotations) static ClassNameReturns a newClassNameinstance for the given fully-qualified class name string.int(package private) CodeWriteremit(CodeWriter out) Returns the enclosing class, likeMapforMap.Entry.static ClassNamestatic ClassNameReturns a class name created from the given parts.static ClassNameget(TypeElement element) Returns the class name forelement.private static PackageElementgetPackage(Element type) private static booleannestedClass(String name) Returns a newClassNameinstance for the specifiednameas nested inside this class.Returns the package name, like"java.util"forMap.Entry.Returns a class that shares the same enclosing package or class.Returns the simple name of this class, like"Entry"forMap.Entry.Returns the top class in this nesting group.Methods inherited from class TypeName
annotated, arrayComponent, box, concatAnnotations, emitAnnotations, equals, get, get, get, get, hashCode, isAnnotated, isBoxedPrimitive, isPrimitive, list, list, toString, unbox
-
Field Details
-
OBJECT
-
names
-
canonicalName
-
-
Constructor Details
-
ClassName
-
ClassName
-
-
Method Details
-
annotated
-
withoutAnnotations
- Overrides:
withoutAnnotationsin classTypeName
-
packageName
Returns the package name, like"java.util"forMap.Entry. -
enclosingClassName
-
topLevelClassName
Returns the top class in this nesting group. Equivalent to chained calls toenclosingClassName()until the result's enclosing class is null. -
nestedClass
-
simpleNames
-
peerClass
-
simpleName
-
get
-
bestGuess
Returns a newClassNameinstance 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 throwIllegalArgumentExceptionotherwise. For that reason,get(Class)andget(Class)should be preferred as they can correctly createClassNameinstances without such restrictions. -
get
-
get
Returns the class name forelement. -
isClassOrInterface
-
getPackage
-
compareTo
- Specified by:
compareToin interfaceComparable<ClassName>
-
emit
- Overrides:
emitin classTypeName- Throws:
IOException
-