- All Superinterfaces:
Comparable<TypeName>
- All Known Implementing Classes:
DefaultTypeName
TypeName is similar to
Type in its most basic use case. The name() returns the package +
class name tuple for the given type (i.e., the canonical type name).
This class also provides a number of methods that are typically found in Class that can be used to avoid
classloading resolution:
packageName()andclassName()- access to the package and simple class names.primitive()andarray()- access to flags that is typically found inClass.
generic()- true when this type is declared to include generics (i.e., has type arguments).wildcard()- true if using wildcard generics usage.typeArguments()- access to generics / parametrized type information.
declaredName()andfqName().
-
Method Summary
Modifier and TypeMethodDescriptionbooleanarray()Functions the same asClass.isArray().Functions the same asClass.getSimpleName().Typically used as part of code-gen, when ".class" is tacked onto the suffix of what this returns.fqName()The fully qualified type name.booleangeneric()Indicates whether this type is using generics.default booleanisList()Indicates whether this type is ajava.util.List.default booleanisMap()Indicates whether this type is ajava.util.Map.default booleanIndicates whether this type is ajava.util.Optional.default booleanisSet()Indicates whether this type is ajava.util.Set.name()The base name that includes the package name concatenated with the class name.Functions the same asClass.getPackageName().booleanFunctions the same asClass.isPrimitive().Returns the list of generic type parameters, or an empty list if no generics are in use.booleanwildcard()Indicates whether this type is using wildcard generics.Methods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
packageName
String packageName()Functions the same asClass.getPackageName().- Returns:
- the package name, never null
-
className
String className()Functions the same asClass.getSimpleName().- Returns:
- the simple class name
-
primitive
boolean primitive()Functions the same asClass.isPrimitive().- Returns:
- true if this type represents a primitive type.
-
array
boolean array()Functions the same asClass.isArray().- Returns:
- true if this type represents a primitive array [].
-
generic
boolean generic()Indicates whether this type is using generics.- Returns:
- used to represent a generic (e.g., "Optional<CB>").
-
wildcard
boolean wildcard()Indicates whether this type is using wildcard generics.- Returns:
- used to represent a wildcard (e.g., "? extends SomeType").
-
isList
default boolean isList()Indicates whether this type is ajava.util.List.- Returns:
- if this is a list
-
isSet
default boolean isSet()Indicates whether this type is ajava.util.Set.- Returns:
- if this is a set
-
isMap
default boolean isMap()Indicates whether this type is ajava.util.Map.- Returns:
- if this is a map
-
isOptional
default boolean isOptional()Indicates whether this type is ajava.util.Optional.- Returns:
- if this is an optional
-
typeArguments
Returns the list of generic type parameters, or an empty list if no generics are in use.- Returns:
- the type arguments of this type, if this type supports generics/parameterized type.
-
declaredName
String declaredName()Typically used as part of code-gen, when ".class" is tacked onto the suffix of what this returns.- Returns:
- same as getName() unless the type is an array, and then will add "[]" to the return.
-
fqName
String fqName()The fully qualified type name. This will include the generic portion of the declaration, as well as any array declaration, etc.- Returns:
- the fully qualified name which includes the use of generics/parameterized types, arrays, etc.
-
name
String name()The base name that includes the package name concatenated with the class name. Similar toType.getTypeName().- Returns:
- the base type name given the set package and class name, but not including the generics/parameterized types.
-