void. This class is an identifier for primitive
types like int and raw reference types like String and List. It also
identifies composite types like char[] and Set<Long>.
Type names are dumb identifiers only and do not model the values they name. For example, the
type name for java.util.List doesn't know about the size() method, the fact that
lists are collections, or even that it accepts a single type parameter.
Instances of this class are immutable value objects that implement equals() and hashCode() properly.
Primitives and void are constants that you can reference directly: see INT, DOUBLE, and VOID.
In an annotation processor you can get a type name instance for a type mirror by calling
get(TypeMirror). In reflection code, you can use get(Type).
Create new reference types like com.example.HelloWorld with ClassName#get(String, String, String.. To build composite types like char[] and
Set<Long>, use the factory methods on ArrayTypeName, ParameterizedTypeName, TypeVariableName, and WildcardTypeName.
| Modifier and Type | Field and Description |
|---|---|
| public final List | |
| public static final TypeName | |
| private static final ClassName | |
| private static final ClassName | |
| private static final ClassName | |
| private static final ClassName | |
| private static final ClassName | |
| private static final ClassName | |
| private static final ClassName | |
| private static final ClassName | |
| private static final ClassName | |
| public static final TypeName | |
| private String | cachedString
Lazily-initialized toString of this type name. |
| public static final TypeName | |
| public static final TypeName | |
| public static final TypeName | |
| public static final TypeName | |
| private final String | keyword
The name of this type if it is a keyword, or null. |
| public static final TypeName | |
| public static final ClassName | |
| public static final TypeName | |
| public static final TypeName |
| Access | Constructor and Description |
|---|---|
| private | |
| private | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final TypeName | |
| public TypeName | |
| pack-priv static TypeName | |
| pack-priv static ArrayTypeName | |
| public TypeName | |
| protected final List | |
| pack-priv CodeWriter | |
| pack-priv CodeWriter | |
| public final boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| public static TypeName | |
| pack-priv static TypeName | |
| public static TypeName | |
| pack-priv static TypeName | |
| public final int | |
| public boolean | |
| public boolean | |
| public boolean | |
| pack-priv static List | |
| pack-priv static List | |
| public final String | |
| public TypeName | |
| public TypeName |
| annotations | back to summary |
|---|---|
| public final List<AnnotationSpec> annotations | |
| BOOLEAN | back to summary |
|---|---|
| public static final TypeName BOOLEAN | |
| BOXED_BOOLEAN | back to summary |
|---|---|
| private static final ClassName BOXED_BOOLEAN | |
| BOXED_BYTE | back to summary |
|---|---|
| private static final ClassName BOXED_BYTE | |
| BOXED_CHAR | back to summary |
|---|---|
| private static final ClassName BOXED_CHAR | |
| BOXED_DOUBLE | back to summary |
|---|---|
| private static final ClassName BOXED_DOUBLE | |
| BOXED_FLOAT | back to summary |
|---|---|
| private static final ClassName BOXED_FLOAT | |
| BOXED_INT | back to summary |
|---|---|
| private static final ClassName BOXED_INT | |
| BOXED_LONG | back to summary |
|---|---|
| private static final ClassName BOXED_LONG | |
| BOXED_SHORT | back to summary |
|---|---|
| private static final ClassName BOXED_SHORT | |
| BOXED_VOID | back to summary |
|---|---|
| private static final ClassName BOXED_VOID | |
| BYTE | back to summary |
|---|---|
| public static final TypeName BYTE | |
| cachedString | back to summary |
|---|---|
| private String cachedString Lazily-initialized toString of this type name. | |
| CHAR | back to summary |
|---|---|
| public static final TypeName CHAR | |
| DOUBLE | back to summary |
|---|---|
| public static final TypeName DOUBLE | |
| FLOAT | back to summary |
|---|---|
| public static final TypeName FLOAT | |
| INT | back to summary |
|---|---|
| public static final TypeName INT | |
| keyword | back to summary |
|---|---|
| private final String keyword The name of this type if it is a keyword, or null. | |
| LONG | back to summary |
|---|---|
| public static final TypeName LONG | |
| OBJECT | back to summary |
|---|---|
| public static final ClassName OBJECT | |
| SHORT | back to summary |
|---|---|
| public static final TypeName SHORT | |
| VOID | back to summary |
|---|---|
| public static final TypeName VOID | |
| TypeName | back to summary |
|---|---|
| private TypeName(String keyword) | |
| TypeName | back to summary |
|---|---|
| private TypeName(String keyword, List<AnnotationSpec> annotations) | |
| TypeName | back to summary |
|---|---|
| pack-priv TypeName(List<AnnotationSpec> annotations) | |
| annotated | back to summary |
|---|---|
| public final TypeName annotated(AnnotationSpec... annotations) | |
| annotated | back to summary |
|---|---|
| public TypeName annotated(List<AnnotationSpec> annotations) | |
| arrayComponent | back to summary |
|---|---|
| pack-priv static TypeName arrayComponent(TypeName type) Returns the array component of | |
| asArray | back to summary |
|---|---|
| pack-priv static ArrayTypeName asArray(TypeName type) Returns | |
| box | back to summary |
|---|---|
| public TypeName box() Returns a boxed type if this is a primitive type (like | |
| concatAnnotations | back to summary |
|---|---|
| protected final List | |
| emit | back to summary |
|---|---|
| pack-priv CodeWriter emit(CodeWriter out) throws IOException | |
| emitAnnotations | back to summary |
|---|---|
| pack-priv CodeWriter emitAnnotations(CodeWriter out) throws IOException | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| get | back to summary |
|---|---|
| public static TypeName get(TypeMirror mirror) Returns a type name equivalent to | |
| get | back to summary |
|---|---|
| pack-priv static TypeName get(TypeMirror mirror, final Map<TypeParameterElement, TypeVariableName> typeVariables) | |
| get | back to summary |
|---|---|
| public static TypeName get(Type type) Returns a type name equivalent to | |
| get | back to summary |
|---|---|
| pack-priv static TypeName get(Type type, Map<Type, TypeVariableName> map) | |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isAnnotated | back to summary |
|---|---|
| public boolean isAnnotated() | |
| isBoxedPrimitive | back to summary |
|---|---|
| public boolean isBoxedPrimitive() Returns true if this is a boxed primitive type like | |
| isPrimitive | back to summary |
|---|---|
| public boolean isPrimitive() Returns true if this is a primitive type like | |
| list | back to summary |
|---|---|
| pack-priv static List Converts an array of types to a list of type names. | |
| list | back to summary |
|---|---|
| pack-priv static List | |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| unbox | back to summary |
|---|---|
| public TypeName unbox() Returns an unboxed type if this is a boxed primitive type (like
| |
| withoutAnnotations | back to summary |
|---|---|
| public TypeName withoutAnnotations() | |