Class ClassNameImpl
java.lang.Object
org.tquadrat.foundation.javacomposer.internal.TypeNameImpl
org.tquadrat.foundation.javacomposer.internal.ClassNameImpl
- All Implemented Interfaces:
Comparable<ClassName>,ClassName,TypeName
@ClassVersion(sourceVersion="$Id: ClassNameImpl.java 1105 2024-02-28 12:58:46Z tquadrat $")
@API(status=INTERNAL,
since="0.0.5")
public final class ClassNameImpl
extends TypeNameImpl
implements ClassName
The implementation of
ClassName
for a fully-qualified class name for top-level and member classes.- Modified by:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: ClassNameImpl.java 1105 2024-02-28 12:58:46Z tquadrat $
- Since:
- 0.0.5
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.javacomposer.internal.ClassNameImpl"
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClassNameImplThe class name forBoolean.static final ClassNameImplThe class name forByte.static final ClassNameImplThe class name forCharacter.static final ClassNameImplThe class name forDouble.static final ClassNameImplThe class name forFloat.static final ClassNameImplThe class name forInteger.static final ClassNameImplThe class name forLong.static final ClassNameImplThe class name forShort.static final ClassNameImplThe class name forVoid.private final StringThe full class name likejava.util.Map.Entry.private final Optional<ClassNameImpl> The enclosing class, or empty if this is not enclosed in another class.private final StringThe package name of this class, or the empty String if this is in the default package.private final StringThe name for this class name, likeEntryforjava.util.Map.Entry.static final ClassNameImplThe class name forObject.Fields inherited from class org.tquadrat.foundation.javacomposer.internal.TypeNameImpl
BOOLEAN_PRIMITIVE, BYTE_PRIMITIVE, CHAR_PRIMITIVE, DOUBLE_PRIMITIVE, FLOAT_PRIMITIVE, INT_PRIMITIVE, LONG_PRIMITIVE, SHORT_PRIMITIVE, VOID_PRIMITIVE -
Constructor Summary
ConstructorsConstructorDescriptionClassNameImpl(CharSequence packageName, Optional<ClassNameImpl> enclosingClassName, CharSequence simpleName) Creates a newClassNameImplinstance.ClassNameImpl(CharSequence packageName, Optional<ClassNameImpl> enclosingClassName, CharSequence simpleName, List<AnnotationSpecImpl> annotations) Creates a newClassNameImplinstance.ClassNameImpl(CharSequence packageName, ClassNameImpl enclosingClassName, CharSequence simpleName) Creates a newClassNameImplinstance.ClassNameImpl(CharSequence packageName, ClassNameImpl enclosingClassName, CharSequence simpleName, List<AnnotationSpecImpl> annotations) Creates a newClassNameImplinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal ClassNameImplannotated(List<AnnotationSpec> annotations) Creates a new instance for an implementation ofTypeNameas a copy of this one, but with the given annotations added.final StringReturns the canonical form of the class name.final intfinal CodeWriteremit(CodeWriter out) Emits this type name instance to the givenCodeWriter.private final List<ClassNameImpl> Returns all enclosing classes inthis, outermost first.final Optional<ClassNameImpl> Returns the enclosing class, likeMapforjava.util.Map.Entry.static final ClassNameImplfrom(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 final ClassNameImplCreates a newClassNameinstance from an instance ofClass.static final ClassNameImplfrom(TypeElement element) Returns the class name for the givenTypeElementinstance.final booleanChecks whether this type name is annotated.final ClassNameImplnestedClass(CharSequence name) Returns a new instance for an implementation ofClassNamefor the specifiednameas nested inside this class.final StringReturns the package name, likejava.utilforjava.util.Map.Entry.Returns the enclosing class, likeMapforjava.util.Map.Entry.final ClassNameImplpeerClass(CharSequence name) Creates a class that shares the same enclosing package or class.final StringReturns the binary name of a class, as used by reflection.final StringReturns the simple name of this class, likeEntryforjava.util.Map.Entry.Returns a list of the simple names for this nesting group.final ClassNameImplReturns the top class in this nesting group.final ClassNameImplCreates a new instance for an implementation ofTypeNameas a copy of this one, but without any annotations.Methods inherited from class org.tquadrat.foundation.javacomposer.internal.TypeNameImpl
annotations, asArray, box, concatAnnotations, emitAnnotations, equals, from, from, from, from, hashCode, isBoxedPrimitive, isPrimitive, list, list, toString, unboxMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tquadrat.foundation.javacomposer.TypeName
annotated, box, hashCode, isBoxedPrimitive, isPrimitive, toString, unbox
-
Field Details
-
BOXED_BOOLEAN
The class name forBoolean. -
BOXED_BYTE
The class name forByte. -
BOXED_CHAR
The class name forCharacter. -
BOXED_DOUBLE
The class name forDouble. -
BOXED_FLOAT
The class name forFloat. -
BOXED_INT
The class name forInteger. -
BOXED_LONG
The class name forLong. -
BOXED_SHORT
The class name forShort. -
BOXED_VOID
The class name forVoid. -
OBJECT
The class name forObject. -
m_CanonicalName
The full class name likejava.util.Map.Entry. -
m_EnclosingClassName
The enclosing class, or empty if this is not enclosed in another class. -
m_PackageName
The package name of this class, or the empty String if this is in the default package. -
m_SimpleName
The name for this class name, likeEntryforjava.util.Map.Entry.
-
-
Constructor Details
-
ClassNameImpl
public ClassNameImpl(CharSequence packageName, ClassNameImpl enclosingClassName, CharSequence simpleName) Creates a newClassNameImplinstance.- Parameters:
packageName- The name of the package for the new class name.enclosingClassName- The name of the enclosing class; can benullin case of a top level class.simpleName- The name of the class.
-
ClassNameImpl
public ClassNameImpl(CharSequence packageName, Optional<ClassNameImpl> enclosingClassName, CharSequence simpleName) Creates a newClassNameImplinstance.- Parameters:
packageName- The name of the package for the new class name.enclosingClassName- The name of the enclosing class; can be empty in case of a top level class.simpleName- The name of the class.
-
ClassNameImpl
public ClassNameImpl(CharSequence packageName, ClassNameImpl enclosingClassName, CharSequence simpleName, List<AnnotationSpecImpl> annotations) Creates a newClassNameImplinstance.- Parameters:
packageName- The name of the package for the new class name.enclosingClassName- The name of the enclosing class; can benullin case of a top level class.simpleName- The name of the class.annotations- The annotations for this class name.
-
ClassNameImpl
public ClassNameImpl(CharSequence packageName, Optional<ClassNameImpl> enclosingClassName, CharSequence simpleName, List<AnnotationSpecImpl> annotations) Creates a newClassNameImplinstance.- Parameters:
packageName- The name of the package for the new class name.enclosingClassName- The name of the enclosing class.simpleName- The name of the class.annotations- The annotations for this class name.
-
-
Method Details
-
annotated
Creates a new instance for an implementation ofTypeNameas a copy of this one, but with the given annotations added. -
compareTo
- Specified by:
compareToin interfaceClassName- Specified by:
compareToin interfaceComparable<ClassName>
-
canonicalName
Returns the canonical form of the class name.- Specified by:
canonicalNamein interfaceClassName- Returns:
- The canonical name.
-
emit
Emits this type name instance to the givenCodeWriter.- Overrides:
emitin classTypeNameImpl- Parameters:
out- The code writer.- Returns:
- The code writer.
- Throws:
UncheckedIOException- Something went wrong when emitting to the output target.
-
enclosingClasses
Returns all enclosing classes inthis, outermost first.- Returns:
- The enclosing classes.
-
enclosingClassName
Returns the enclosing class, likeMapforjava.util.Map.Entry. The return value will be empty if this class is not nested in another class.- Returns:
- An instance of
Optionalthat holds the name of the enclosing class.
-
from
Creates a newClassNameinstance from an instance ofClass.- Parameters:
sourceClass- The instance ofjava.lang.Class.- Returns:
- The respective instance of
ClassName.
-
from
Returns the class name for the givenTypeElementinstance.- Parameters:
element- The type element instance.- Returns:
- The new class name instance.
-
from
@API(status=STABLE, since="0.2.0") public static final ClassNameImpl 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
ClassNameinstance.
-
isAnnotated
Checks whether this type name is annotated.- Specified by:
isAnnotatedin interfaceClassName- Specified by:
isAnnotatedin interfaceTypeName- Overrides:
isAnnotatedin classTypeNameImpl- Returns:
trueif it is annotated,falseotherwise.
-
nestedClass
Returns a new instance for an implementation ofClassNamefor the specifiednameas nested inside this class.- Specified by:
nestedClassin interfaceClassName- Parameters:
name- The name for the new nested class.- Returns:
- The new instance.
-
packageName
Returns the package name, likejava.utilforjava.util.Map.Entry. Returns the empty String for the default package.- Specified by:
packageNamein interfaceClassName- Returns:
- The package name.
-
parentClass
Returns the enclosing class, likeMapforjava.util.Map.Entry. The return value will be empty if this class is not nested in another class.- Specified by:
parentClassin interfaceClassName- Returns:
- An instance of
Optionalthat holds the name of the enclosing class.
-
peerClass
Creates a class that shares the same enclosing package or class. If this class is enclosed by another class, this is equivalent toenclosingClassName().Optional.get().nestedClass(name). Otherwise, it is equivalent toget(packageName(),name). -
reflectionName
Returns the binary name of a class, as used by reflection.- Specified by:
reflectionNamein interfaceClassName- Returns:
- The binary name.
-
simpleName
Returns the simple name of this class, likeEntryforjava.util.Map.Entry.- Specified by:
simpleNamein interfaceClassName- Returns:
- The simple name.
-
simpleNames
Returns a list of the simple names for this nesting group.- Specified by:
simpleNamesin interfaceClassName- Returns:
- The simple names.
-
topLevelClassName
Returns the top class in this nesting group. Equivalent to chained calls toenclosingClassName()until the result's enclosing class is not present.- Specified by:
topLevelClassNamein interfaceClassName- Returns:
- The name of the top level class.
-
withoutAnnotations
Creates a new instance for an implementation ofTypeNameas a copy of this one, but without any annotations.- Specified by:
withoutAnnotationsin interfaceClassName- Specified by:
withoutAnnotationsin interfaceTypeName- Overrides:
withoutAnnotationsin classTypeNameImpl- Returns:
- The new instance.
-
