public TypeMirror wrapIterable(TypeMirror typeMirror) { return types.getDeclaredType(iterableElement, typeMirror); }
DeclaredType makeIterableTypeOf(TypeMirror resolved) { return knife.types.getDeclaredType(knife.accessors.iterableElement, resolved); }
private static DeclaredType getTypeMirror(Types types, Elements elements, Class<?> reflected) { TypeElement typeElement = elements.getTypeElement(reflected.getName()); checkState(typeElement != null, "type must be present: %s", reflected.getName()); return types.getDeclaredType(typeElement); }
private TypeMirror getArrayListType(String elementType) { TypeElement arrayList = processingEnv.getElementUtils().getTypeElement("java.util.ArrayList"); TypeMirror elType = processingEnv.getElementUtils().getTypeElement(elementType).asType(); return processingEnv.getTypeUtils().getDeclaredType(arrayList, elType); }
private TypeMirror getWildcardType(String type, String elementType) { TypeElement arrayList = processingEnv.getElementUtils().getTypeElement(type); TypeMirror elType = processingEnv.getElementUtils().getTypeElement(elementType).asType(); return processingEnv.getTypeUtils() .getDeclaredType(arrayList, processingEnv.getTypeUtils().getWildcardType(elType, null)); }
private void createDaoParametrizedTypes() { daoTypeElement = helper.typeElementFromQualifiedName(OrmLiteClasses.DAO); runtimeExceptionDaoTypeElement = helper.typeElementFromQualifiedName(OrmLiteClasses.RUNTIME_EXCEPTION_DAO); Types typeUtils = helper.getTypeUtils(); TypeMirror wildcardType = typeUtils.getWildcardType(null, null); daoParametrizedType = helper.getTypeUtils().getDeclaredType(daoTypeElement, wildcardType, wildcardType); runtimeExceptionDaoParametrizedType = helper.getTypeUtils().getDeclaredType(runtimeExceptionDaoTypeElement, wildcardType, wildcardType); } }
public DeclaredType getTypedRuntimeExceptionDao(Element element) { if (runtimeExceptionDaoTypeElement == null) { createDaoParametrizedTypes(); } return helper.getTypeUtils().getDeclaredType(runtimeExceptionDaoTypeElement, getEntityType(element), getEntityIdType(element)); }
public DeclaredType getTypedDao(Element element) { if (daoTypeElement == null) { createDaoParametrizedTypes(); } return helper.getTypeUtils().getDeclaredType(daoTypeElement, getEntityType(element), getEntityIdType(element)); }
private IJExpression instantiateArrayList(TypeMirror viewType, EComponentWithViewSupportHolder holder, String name) { TypeElement arrayListTypeElement = annotationHelper.typeElementFromQualifiedName(CanonicalNameConstants.ARRAYLIST); DeclaredType arrayListType = getProcessingEnvironment().getTypeUtils().getDeclaredType(arrayListTypeElement, viewType); AbstractJClass arrayListClass = codeModelHelper.typeMirrorToJClass(arrayListType); return holder.getOnViewChangedBodyBeforeInjectionBlock().decl(arrayListClass, name, _new(arrayListClass)); }
private TypeMirror getRealElementType(Element element) { AnnotationMirror mirror = TypeUtils.getAnnotationMirrorOfType(element, ManyToOne.class); if (mirror == null) { mirror = TypeUtils.getAnnotationMirrorOfType(element, OneToOne.class); } if (mirror != null) { return TypeUtils.getAnnotationValueAsTypeMirror(mirror, "targetEntity"); } mirror = TypeUtils.getAnnotationMirrorOfType(element, OneToMany.class); if (mirror == null) { mirror = TypeUtils.getAnnotationMirrorOfType(element, ManyToMany.class); } if (mirror != null) { TypeMirror typeArg = TypeUtils.getAnnotationValueAsTypeMirror(mirror, "targetEntity"); TypeMirror erasure = types.erasure(element.asType()); TypeElement typeElement = (TypeElement) types.asElement(erasure); if (typeElement != null && typeArg != null) { if (typeElement.getTypeParameters().size() == 1) { return types.getDeclaredType(typeElement, typeArg); } else if (typeElement.getTypeParameters().size() == 2) { if (element.asType() instanceof DeclaredType) { TypeMirror first = ((DeclaredType) element.asType()).getTypeArguments().get(0); return types.getDeclaredType(typeElement, first, typeArg); } } } } return null; }
processingEnv.getTypeUtils().getDeclaredType( processingEnv.getElementUtils().getTypeElement(type.getName().replace('$', '.'))) : null;
/** * Returns the {@link DeclaredType} for the given class name. * * @param className A fully qualified class name, e.g. "java.lang.String". * * @return A {@link DeclaredType} representing the type with the given name, * or null, if no such type exists. */ public DeclaredType getDeclaredTypeByName(String className) { TypeElement typeElement = elementUtils.getTypeElement( className ); return typeElement != null ? typeUtils.getDeclaredType( typeElement ) : null; }
private static TypeMirror multiset( TypeMirror elementType, Elements elements, Types types) { TypeElement multisetType = elements.getTypeElement(Multiset.class.getName()); return types.getDeclaredType(multisetType, elementType); } }
/** * Utility method to look up raw types from class literals. */ public DeclaredType findType(Class<?> clazz) { return types.getDeclaredType(elements.getTypeElement(clazz.getCanonicalName())); }
private static TypeMirror listMultimap( TypeMirror keyType, TypeMirror valueType, Elements elements, Types types) { TypeElement listMultimapType = elements.getTypeElement(ListMultimap.class.getName()); return types.getDeclaredType(listMultimapType, keyType, valueType); } }
private static TypeMirror setMultimap( TypeMirror keyType, TypeMirror valueType, Elements elements, Types types) { TypeElement setMultimapType = elements.getTypeElement(SetMultimap.class.getName()); return types.getDeclaredType(setMultimapType, keyType, valueType); } }
private static TypeMirror wildcardSuperSet( TypeMirror elementType, Elements elements, Types types) { TypeElement setType = elements.getTypeElement(Set.class.getName()); return types.getWildcardType(null, types.getDeclaredType(setType, elementType)); } }
/** * Returns {@code ? super List<elementType>}. */ private static TypeMirror wildcardSuperList( TypeMirror elementType, Elements elements, Types types) { TypeElement listType = elements.getTypeElement(List.class.getName()); return types.getWildcardType(null, types.getDeclaredType(listType, elementType)); } }
private static TypeMirror wildcardSuperMap( TypeMirror keyType, TypeMirror valueType, Elements elements, Types types) { TypeElement mapType = elements.getTypeElement(Map.class.getName()); return types.getWildcardType(null, types.getDeclaredType(mapType, keyType, valueType)); } }
private static TypeMirror wildcardSuperSortedSet( TypeMirror elementType, Elements elements, Types types) { TypeElement setType = elements.getTypeElement(SortedSet.class.getName()); return types.getWildcardType(null, types.getDeclaredType(setType, elementType)); } }