@Internal public class GenericUtils extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
GenericUtils(javax.lang.model.util.Elements elementUtils,
javax.lang.model.util.Types typeUtils,
ModelUtils modelUtils) |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> |
alignNewGenericsInfo(java.util.List<? extends javax.lang.model.element.TypeParameterElement> typeParameters,
java.util.List<? extends javax.lang.model.type.TypeMirror> typeArguments,
java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> genericsInfo)
Takes the bound generic information and re-aligns for the new type.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror>> |
alignNewGenericsInfo(javax.lang.model.element.TypeElement typeElement,
java.util.List<? extends javax.lang.model.type.TypeMirror> typeArguments,
java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> genericsInfo)
Takes a type element and the bound generic information and re-aligns for the new type.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror>> |
buildGenericTypeArgumentElementInfo(javax.lang.model.element.Element element)
Builds type argument information for the given type.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> |
buildGenericTypeArgumentInfo(javax.lang.model.element.Element element)
Builds type argument information for the given type.
|
protected java.util.Optional<javax.lang.model.type.TypeMirror> |
getFirstTypeArgument(javax.lang.model.type.TypeMirror type)
Return the first type argument for the given type mirror.
|
protected javax.lang.model.type.TypeMirror |
interfaceGenericTypeFor(javax.lang.model.element.TypeElement element,
java.lang.Class interfaceType)
Finds the generic type for the given interface for the given class element.
|
protected javax.lang.model.type.TypeMirror |
interfaceGenericTypeFor(javax.lang.model.element.TypeElement element,
java.lang.String interfaceName)
Finds the generic type for the given interface for the given class element.
|
java.util.List<? extends javax.lang.model.type.TypeMirror> |
interfaceGenericTypesFor(javax.lang.model.element.TypeElement element,
java.lang.String interfaceName)
Finds the generic types for the given interface for the given class element.
|
protected java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> |
resolveBoundGenerics(javax.lang.model.element.TypeElement declaringType,
javax.lang.model.type.TypeMirror returnType,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror>> genericsInfo)
Resolve bound types for the given return type.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
resolveBoundTypes(javax.lang.model.type.DeclaredType type)
Resolve bound types for the given declared type.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
resolveGenericTypes(javax.lang.model.type.DeclaredType type,
javax.lang.model.element.TypeElement typeElement,
java.util.Map<java.lang.String,java.lang.Object> boundTypes)
Resolve the generic type arguments for the given type mirror and bound type arguments.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
resolveGenericTypes(javax.lang.model.type.TypeMirror type,
java.util.Map<java.lang.String,java.lang.Object> boundTypes)
Resolve the generic type arguments for the given type mirror and bound type arguments.
|
protected java.lang.Object |
resolveTypeReference(javax.lang.model.type.TypeMirror mirror) |
protected java.lang.Object |
resolveTypeReference(javax.lang.model.type.TypeMirror mirror,
java.util.Map<java.lang.String,java.lang.Object> boundTypes)
Resolve a type reference to use for the given type mirror taking into account generic type variables.
|
protected javax.lang.model.type.DeclaredType |
resolveTypeVariable(javax.lang.model.element.Element element,
javax.lang.model.type.TypeVariable typeVariable)
Resolve the first type argument to a parameterized type.
|
protected GenericUtils(javax.lang.model.util.Elements elementUtils, javax.lang.model.util.Types typeUtils, ModelUtils modelUtils)
elementUtils
- The Elements
typeUtils
- The Types
modelUtils
- The ModelUtils
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> buildGenericTypeArgumentInfo(@NonNull javax.lang.model.element.Element element)
element
- The elementpublic java.util.Map<java.lang.String,java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror>> buildGenericTypeArgumentElementInfo(@NonNull javax.lang.model.element.Element element)
element
- The elementprotected javax.lang.model.type.TypeMirror interfaceGenericTypeFor(javax.lang.model.element.TypeElement element, java.lang.Class interfaceType)
For example, for class AProvider implements Provider
element = AProvider
interfaceType = interface javax.inject.Provider.class
return A
element
- The class elementinterfaceType
- The interfaceprotected javax.lang.model.type.TypeMirror interfaceGenericTypeFor(javax.lang.model.element.TypeElement element, java.lang.String interfaceName)
For example, for class AProvider implements Provider<A>
element = AProvider
interfaceName = interface javax.inject.Provider
return A
element
- The class elementinterfaceName
- The interfacepublic java.util.List<? extends javax.lang.model.type.TypeMirror> interfaceGenericTypesFor(javax.lang.model.element.TypeElement element, java.lang.String interfaceName)
element
- The class elementinterfaceName
- The interfaceprotected java.util.Optional<javax.lang.model.type.TypeMirror> getFirstTypeArgument(javax.lang.model.type.TypeMirror type)
String
.type
- The typeprotected java.util.Map<java.lang.String,java.lang.Object> resolveGenericTypes(javax.lang.model.type.TypeMirror type, java.util.Map<java.lang.String,java.lang.Object> boundTypes)
type
- The type mirrorboundTypes
- The bound types (such as those declared on the class)protected java.util.Map<java.lang.String,java.lang.Object> resolveGenericTypes(javax.lang.model.type.DeclaredType type, javax.lang.model.element.TypeElement typeElement, java.util.Map<java.lang.String,java.lang.Object> boundTypes)
type
- The declaring typetypeElement
- The type elementboundTypes
- The bound typesprotected java.lang.Object resolveTypeReference(javax.lang.model.type.TypeMirror mirror)
mirror
- The TypeMirror
protected java.lang.Object resolveTypeReference(javax.lang.model.type.TypeMirror mirror, java.util.Map<java.lang.String,java.lang.Object> boundTypes)
mirror
- The mirrorboundTypes
- The already bound types for any type variableprotected javax.lang.model.type.DeclaredType resolveTypeVariable(javax.lang.model.element.Element element, javax.lang.model.type.TypeVariable typeVariable)
element
- The type elementtypeVariable
- The type variableprotected java.util.Map<java.lang.String,java.lang.Object> resolveBoundTypes(javax.lang.model.type.DeclaredType type)
type
- The declaring typeprotected java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> resolveBoundGenerics(javax.lang.model.element.TypeElement declaringType, javax.lang.model.type.TypeMirror returnType, java.util.Map<java.lang.String,java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror>> genericsInfo)
declaringType
- The declaring typereturnType
- The return typegenericsInfo
- The declaring generics infopublic java.util.Map<java.lang.String,java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror>> alignNewGenericsInfo(javax.lang.model.element.TypeElement typeElement, java.util.List<? extends javax.lang.model.type.TypeMirror> typeArguments, java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> genericsInfo)
typeElement
- The type elementtypeArguments
- The type argumentsgenericsInfo
- The generic infopublic java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> alignNewGenericsInfo(java.util.List<? extends javax.lang.model.element.TypeParameterElement> typeParameters, java.util.List<? extends javax.lang.model.type.TypeMirror> typeArguments, java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> genericsInfo)
typeParameters
- The type parameterstypeArguments
- The type argumentsgenericsInfo
- The generic info