Class TypeClass
- java.lang.Object
-
- org.inferred.freebuilder.processor.source.ValueType
-
- org.inferred.freebuilder.processor.source.Type
-
- org.inferred.freebuilder.processor.source.TypeClass
-
- All Implemented Interfaces:
Excerpt
public class TypeClass extends Type
Representation of a class or interface element.When used as an excerpt or
Type, it acts as a prototypical type of the class. This is the element's invocation on the type variables corresponding to its own formal type parameters. For example, theTypeClassofEnumSetwould appear in code asEnumSet<E>. This is probably the most common use of a type class in code generation.The
declaration()anddeclarationParameters()methods, on the other hand, return excerpts reflecting the type element. For example, the declaration ofEnumSetwould beEnumSet<E extends Enum<E>>.A hybrid of a
TypeElementand its prototypicalDeclaredType.- See Also:
Element.asType()
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.inferred.freebuilder.processor.source.Type
Type.JavadocLink, Type.TypeImpl
-
Nested classes/interfaces inherited from class org.inferred.freebuilder.processor.source.ValueType
ValueType.FieldReceiver
-
-
Field Summary
Fields Modifier and Type Field Description private QualifiedNamequalifiedNameprivate java.util.List<javax.lang.model.element.TypeParameterElement>typeParameters
-
Constructor Summary
Constructors Constructor Description TypeClass(QualifiedName qualifiedName, java.util.Collection<? extends javax.lang.model.element.TypeParameterElement> typeParameters)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddDeclarationParameters(SourceBuilder source, java.util.List<javax.lang.model.element.TypeParameterElement> typeParameters)protected voidaddFields(ValueType.FieldReceiver fields)Implement this method to report the name and value of each field.Excerptdeclaration()Returns a source excerpt suitable for declaring this type element.ExcerptdeclarationParameters()Returns a source excerpt of the type parameters of this type element, including bounds and angle brackets.private static booleanextendsObject(javax.lang.model.element.TypeParameterElement element)static TypeClassfrom(javax.lang.model.element.TypeElement typeElement)static TypeClassfromNonGeneric(java.lang.Class<?> cls)QualifiedNamegetQualifiedName()Returns the qualified name of the type class.protected java.util.List<javax.lang.model.element.TypeParameterElement>getTypeParameters()java.lang.StringtoString()-
Methods inherited from class org.inferred.freebuilder.processor.source.Type
addTo, constructor, diamondOperator, from, from, getSimpleName, isParameterized, javadocLink, javadocMethodLink, javadocNoArgMethodLink, typeParameters, withWildcards
-
-
-
-
Field Detail
-
qualifiedName
private final QualifiedName qualifiedName
-
typeParameters
private final java.util.List<javax.lang.model.element.TypeParameterElement> typeParameters
-
-
Constructor Detail
-
TypeClass
TypeClass(QualifiedName qualifiedName, java.util.Collection<? extends javax.lang.model.element.TypeParameterElement> typeParameters)
-
-
Method Detail
-
from
public static TypeClass from(javax.lang.model.element.TypeElement typeElement)
-
fromNonGeneric
public static TypeClass fromNonGeneric(java.lang.Class<?> cls)
-
getQualifiedName
public QualifiedName getQualifiedName()
Description copied from class:TypeReturns the qualified name of the type class.- Specified by:
getQualifiedNamein classType
-
declaration
public Excerpt declaration()
Returns a source excerpt suitable for declaring this type element.e.g.
MyType<N extends Number, C extends Consumer<N>>
-
declarationParameters
public Excerpt declarationParameters()
Returns a source excerpt of the type parameters of this type element, including bounds and angle brackets.e.g.
<N extends Number, C extends Consumer<N>>
-
getTypeParameters
protected java.util.List<javax.lang.model.element.TypeParameterElement> getTypeParameters()
- Specified by:
getTypeParametersin classType
-
addFields
protected void addFields(ValueType.FieldReceiver fields)
Description copied from class:ValueTypeImplement this method to report the name and value of each field.
-
addDeclarationParameters
private static void addDeclarationParameters(SourceBuilder source, java.util.List<javax.lang.model.element.TypeParameterElement> typeParameters)
-
extendsObject
private static boolean extendsObject(javax.lang.model.element.TypeParameterElement element)
-
-