private static TypeMirror getErasuredType(TypeMirror typeMirror, TypeElement owner) { if (typeMirror.equals(TypeKind.TYPEVAR)) { TypeMirror ensuredType = ProcessorUtils.erasure(owner, (TypeVariable) typeMirror); if (ensuredType != null) { return ensuredType; } } return typeMirror; } }
public static ExecutableElement getOverrider(TypeElement element, ExecutableElement method, ProcessingEnvironment processingEnv) { List<ExecutableElement> methods = ElementFilter.methodsIn(element.getEnclosedElements()); for (ExecutableElement classMethod : methods) { if (processingEnv.getElementUtils().overrides(classMethod, method, element)) { return classMethod; } } if (element.getSuperclass().getKind().equals(TypeKind.DECLARED)) { return getOverrider((TypeElement)((DeclaredType)element.getSuperclass()).asElement(), method, processingEnv); } return method; } }
public static boolean hasMethod(String name, Element element) { return hasMethod(name, element, true); }
public static boolean isAssignable(TypeMirror mirror, MutableDeclaredType type) { assert mirror != null; assert type != null; if (mirror instanceof DeclaredType) { DeclaredType dt = (DeclaredType) mirror; TypeElement dte = (TypeElement) dt.asElement(); if (isOfType(dte, type)) { return true; } else { return isAssignableFrom(dte, type); } } return false; }
/** * Method determines whether typeElement implements or extends type */ public static boolean isAssignableFrom(TypeElement typeElement, MutableDeclaredType type) { assert typeElement != null; assert type != null; boolean result; result = isOfType(typeElement, type); if (result == true) { return true; } List<? extends TypeMirror> interfaces2 = typeElement.getInterfaces(); TypeMirror superclass = typeElement.getSuperclass(); result = isAssignable(superclass, type); if (result == true) { return true; } for (TypeMirror mirror : interfaces2) { if (isAssignable(mirror, type)) { return true; } } return false; }
if (!ProcessorUtils.hasMethod(processingEnv, Object.class, method)) { } else if (!isDataInterface && !ProcessorUtils.hasMethod(MethodHelper.toSetter(method), owner, true)) { TypeMirror erasuredReturnType = ProcessorUtils.erasure(owner, (TypeVariable) returnType); if (erasuredReturnType != null) { returnType = erasuredReturnType;
String path = domainPathResolver.next(); method = ProcessorUtils.getMethod(MethodHelper.toSetter(path), typeElement); break; case TYPEVAR: TypeMirror erasure = ProcessorUtils.erasure(typeElement, typeMirror.toString()); if (erasure == null) { for (TypeParameterElement parameter: typeElement.getTypeParameters()) {
public static ExecutableElement getMethod(String name, Element element) { return getMethod(name, element, true); }
@Override public boolean appliesFor(VariableElement field, Element element, ProcessingEnvironment pe) { return ProcessorUtils.implementsType(element.asType(), field.asType()); }; };
pw.print(returnType = ProcessorUtils.stripTypeParametersVariables(processingEnv.getTypeUtils().toMutableType(localMethod.getReturnType())), " " + RESULT_VARIABLE_NAME + " = "); final DomainType parameterDomainType = processingEnv.getTransferObjectUtils().getDomainType(ProcessorUtils.stripTypeParametersVariables(parameterDtoType.getDomain())); ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(dtoType)), remoteMethod); ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(domainType)), localMethod); ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(returnType)), remoteMethod); ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(localMethod.getReturnType())), localMethod); returnType = ProcessorUtils.stripTypeParametersTypes(processingEnv.getTypeUtils().toMutableType(remoteMethod.getReturnType()));
parameterElement = parameter; if (parameter.getPropagationType().equals(PropagationType.PROPAGATED_IMUTABLE)) { if (!ProcessorUtils.hasField(processingEnv, converterProviderContextType, constructorParameter.getType(), constructorParameter.getName())) { ProcessorUtils.addField(processingEnv, converterProviderContextType, constructorParameter.getType(), constructorParameter.getName()); if (!ProcessorUtils.hasField(processingEnv, converterProviderContextType, constructorParameter.getType(), constructorParameter.getName())) { ProcessorUtils.addField(processingEnv, converterProviderContextType, constructorParameter.getType(), constructorParameter.getName());
public boolean isSupportedByInterface(TypeElement typeElement) { if (ensureConfiguration(DefaultConfigurationElement.PROCESSING_INTERFACES).size() == 0) { return false; } for (MutableDeclaredType type : ensureConfiguration(DefaultConfigurationElement.PROCESSING_INTERFACES)) { if (ProcessorUtils.isAssignableFrom(typeElement, type)) { return true; } } return false; }
String parameterName = getParameterName(parameter, additionalParameters); if (parameterName == null) { ProcessorUtils.addField(processingEnv, ownerType, processingEnv.getTypeUtils().toMutableType(parameter.asType()), parameter.getSimpleName().toString()); ProcessorUtils.addField(processingEnv, ownerType, additionalParameter.getType(), additionalParameter.getName().toString());
printWriter.print(ProcessorUtils.stripTypeParametersTypes(method.getReturnType()), " "); printWriter.print(", "); printWriter.print(ProcessorUtils.stripTypeParametersTypes(parameter.asType()), " " + parameter.getSimpleName().toString()); i++;
public static boolean isAssignable(TypeMirror mirror, NamedType type) { assert mirror != null; assert type != null; if (mirror instanceof DeclaredType) { DeclaredType dt = (DeclaredType) mirror; TypeElement dte = (TypeElement) dt.asElement(); if (isOfType(dte, type)) { return true; } else { return isAssignableFrom(dte, type); } } return false; }
/** * Method determines whether typeElement implements or extends type */ public static boolean isAssignableFrom(TypeElement typeElement, NamedType type) { assert typeElement != null; assert type != null; boolean result; result = isOfType(typeElement, type); if (result == true) { return true; } List<? extends TypeMirror> interfaces2 = typeElement.getInterfaces(); TypeMirror superclass = typeElement.getSuperclass(); result = isAssignable(superclass, type); if (result == true) { return true; } for (TypeMirror mirror : interfaces2) { if (isAssignable(mirror, type)) { return true; } } return false; }
public static boolean hasMethod(String name, Element element, boolean searchInterfaces) { return getMethod(name, element, searchInterfaces) != null; }
if (implementsType(interfaceType, t2)) { return true; return implementsType(superClassType, t2);
private boolean isAssignable(TypeElement typeElement) { if (ensureConfiguration(DefaultConfigurationType.PROCESSING_INTERFACES, typeElement).size() == 0) { return false; } for (NamedType type : ensureConfiguration(DefaultConfigurationType.PROCESSING_INTERFACES, typeElement)) { if (ProcessorUtils.isAssignableFrom(typeElement, type)) { return true; } } return false; }
public static TypeMirror erasure(TypeElement typeElement, TypeVariable typeVar) { return erasure(typeElement, typeVar.asElement().getSimpleName().toString()); }