Interface ClassName
- All Superinterfaces:
Comparable<ClassName>
,TypeName
- All Known Implementing Classes:
ClassNameImpl
@ClassVersion(sourceVersion="$Id: ClassName.java 1085 2024-01-05 16:23:28Z tquadrat $")
@API(status=STABLE,
since="0.0.5")
public sealed interface ClassName
extends TypeName, Comparable<ClassName>
permits ClassNameImpl
The specification for a fully-qualified class name for top-level and
member classes.
- Author:
- Square,Inc.
- Modified by:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: ClassName.java 1085 2024-01-05 16:23:28Z tquadrat $
- Since:
- 0.0.5
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.javacomposer.ClassName"
-
Method Summary
Modifier and TypeMethodDescriptionannotated
(List<AnnotationSpec> annotations) Creates a new instance for an implementation ofClassName
as a copy of this one, but with the given annotations added.Returns the canonical form of the class name.int
boolean
static ClassName
from
(CharSequence packageName, CharSequence simpleName, CharSequence... simpleNames) Returns a class name created from the given parts.
For example, calling this method with package name"java.util"
and simple names"Map"
and"Entry"
yieldsjava.util.Map.Entry
.static ClassName
Creates a new instance for an implementation ofClassName
from an instance ofClass
.static ClassName
from
(TypeElement element) Returns the class name for the givenTypeElement
instance.boolean
Checks whether this type name is annotated.nestedClass
(CharSequence name) Returns a new instance for an implementation ofClassName
for the specifiedname
as nested inside this class.Returns the package name, likejava.util
forjava.util.Map.Entry
.Returns the enclosing class, likeMap
forjava.util.Map.Entry
.peerClass
(CharSequence name) Creates a class that shares the same enclosing package or class.Returns the binary name of a class, as used by reflection.Returns the simple name of this class, likeEntry
forjava.util.Map.Entry
.Returns a list of the simple names for this nesting group.Returns the top class in this nesting group.Creates a new instance for an implementation ofClassName
as a copy of this one, but without any annotations.Methods inherited from interface org.tquadrat.foundation.javacomposer.TypeName
annotated, box, hashCode, isBoxedPrimitive, isPrimitive, toString, unbox
-
Method Details
-
annotated
Creates a new instance for an implementation ofClassName
as a copy of this one, but with the given annotations added. -
compareTo
- Specified by:
compareTo
in interfaceComparable<ClassName>
-
canonicalName
Returns the canonical form of the class name.- Returns:
- The canonical name.
-
equals
-
from
Creates a new instance for an implementation ofClassName
from an instance ofClass
.- Parameters:
sourceClass
- The instance ofjava.lang.Class
.- Returns:
- The respective instance of
ClassName
.
-
from
Returns the class name for the givenTypeElement
instance.- Parameters:
element
- The type element instance.- Returns:
- The new class name instance.
-
from
@API(status=STABLE, since="0.2.0") static ClassName from(CharSequence packageName, CharSequence simpleName, CharSequence... simpleNames) Returns a class name created from the given parts.
For example, calling this method with package name"java.util"
and simple names"Map"
and"Entry"
yieldsjava.util.Map.Entry
.- Parameters:
packageName
- The package name.simpleName
- The name of the top-level class.simpleNames
- The names of the nested classes, from outer to inner.- Returns:
- The new
ClassName
instance.
-
isAnnotated
boolean isAnnotated()Checks whether this type name is annotated.- Specified by:
isAnnotated
in interfaceTypeName
- Returns:
true
if it is annotated,false
otherwise.
-
nestedClass
Returns a new instance for an implementation ofClassName
for the specifiedname
as nested inside this class.- Parameters:
name
- The name for the new nested class.- Returns:
- The new instance.
-
packageName
Returns the package name, likejava.util
forjava.util.Map.Entry
. Returns the empty String for the default package.- Returns:
- The package name.
-
parentClass
Returns the enclosing class, likeMap
forjava.util.Map.Entry
. The return value will be empty if this class is not nested in another class.- Returns:
- An instance of
Optional
that holds the name of the enclosing class.
-
peerClass
Creates a class that shares the same enclosing package or class.- Parameters:
name
- The name of the peer class to create.- Returns:
- The new instance for the peer class.
-
reflectionName
Returns the binary name of a class, as used by reflection.- Returns:
- The binary name.
-
simpleName
Returns the simple name of this class, likeEntry
forjava.util.Map.Entry
.- Returns:
- The simple name.
-
simpleNames
Returns a list of the simple names for this nesting group.- Returns:
- The simple names.
-
topLevelClassName
Returns the top class in this nesting group.- Returns:
- The name of the top level class.
-
withoutAnnotations
Creates a new instance for an implementation ofClassName
as a copy of this one, but without any annotations.- Specified by:
withoutAnnotations
in interfaceTypeName
- Returns:
- The new instance.
-