@Override public boolean correctReturnType(TypeMirror returnType) { return returnType.getKind() == typeKind; }
private TypeMirror getUpperBound(TypeMirror type) { TypeVariable typeVariable = (TypeVariable) type; return typeVariable.getUpperBound(); }
@Override public String visitArray(ArrayType t, Builder builder) { return t.getComponentType().accept(this, builder) + "[]"; }
private boolean checkIfParameterizedTypeReferenceShouldBeUsed(TypeMirror returnType) { switch (returnType.getKind()) { case DECLARED: return !((DeclaredType) returnType).getTypeArguments().isEmpty(); case ARRAY: ArrayType arrayType = (ArrayType) returnType; TypeMirror componentType = arrayType.getComponentType(); return checkIfParameterizedTypeReferenceShouldBeUsed(componentType); } return false; }
/** Finds the parent binder type in the supplied set, if any. */ private @Nullable TypeElement findParentType(TypeElement typeElement, Set<TypeElement> parents) { TypeMirror type; while (true) { type = typeElement.getSuperclass(); if (type.getKind() == TypeKind.NONE) { return null; } typeElement = (TypeElement) ((DeclaredType) type).asElement(); if (parents.contains(typeElement)) { return typeElement; } } }
public String getType(TypeMirror type) { if (type == null) { return null; } if (type instanceof DeclaredType) { DeclaredType declaredType = (DeclaredType) type; Element enclosingElement = declaredType.asElement().getEnclosingElement(); if (enclosingElement != null && enclosingElement instanceof TypeElement) { return getQualifiedName(enclosingElement) + "$" + declaredType.asElement().getSimpleName().toString(); } else { return getQualifiedName(declaredType.asElement()); } } return type.toString(); }
private boolean typeMatchesExpected( TypeMirror returnType, ExecutableElement executableElement) { if (!(returnType instanceof DeclaredType)) { return false; } List<? extends TypeMirror> typeArguments = ((DeclaredType) returnType).getTypeArguments(); if (typeArguments.size() != 1) { return false; } TypeMirror argument = typeArguments.get(0); String expected = getGlideTypeValue(executableElement); return argument.toString().equals(expected); }
private static boolean isBaseRequestOptions(TypeMirror typeMirror) { return typeMirror.toString().equals("com.bumptech.glide.request.BaseRequestOptions<?>"); }
public void doesNotReturnPrimitive(ExecutableElement element, ElementValidation valid) { if (element.getReturnType().getKind().isPrimitive()) { valid.addError("%s cannot return primitive"); } }
private boolean isInterface(TypeMirror typeMirror) { return typeMirror instanceof DeclaredType && ((DeclaredType) typeMirror).asElement().getKind() == INTERFACE; }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= this.kind.hashCode(); return h; }
private boolean isRootObjectClass(TypeMirror typeMirror) { return typeMirror.getKind() == TypeKind.NONE; }
private static boolean isTypeEqual(TypeMirror typeMirror, String otherType) { return otherType.equals(typeMirror.toString()); }
@Override public String apply(AnnotationMirror input) { return input.getAnnotationType().asElement().toString(); } })
private MethodSpec generateAdditionalRequestManagerMethod(ExecutableElement extensionMethod) { if (extensionMethod.getReturnType().getKind() == TypeKind.VOID) { return generateAdditionalRequestManagerMethodLegacy(extensionMethod); } else { return generateAdditionalRequestManagerMethodNew(extensionMethod); } }
@Override public boolean correctReturnType(TypeMirror returnType) { return returnType.toString().equals(CanonicalNameConstants.STRING); } }, valid);
@Override protected void makeCall(JBlock listenerMethodBody, JInvocation call, TypeMirror returnType) { boolean returnMethodResult = returnType.getKind() != TypeKind.VOID; if (returnMethodResult) { listenerMethodBody._return(call); } else { listenerMethodBody.add(call); listenerMethodBody._return(JExpr.TRUE); } }
/** Uses both {@link Types#erasure} and string manipulation to strip any generic types. */ private String doubleErasure(TypeMirror elementType) { String name = typeUtils.erasure(elementType).toString(); int typeParamStart = name.indexOf('<'); if (typeParamStart != -1) { name = name.substring(0, typeParamStart); } return name; }
@Override protected void makeCall(JBlock listenerMethodBody, JInvocation call, TypeMirror returnType) { boolean returnMethodResult = returnType.getKind() != TypeKind.VOID; if (returnMethodResult) { listenerMethodBody._return(call); } else { listenerMethodBody.add(call); listenerMethodBody._return(JExpr.TRUE); } }
@Override protected void makeCall(JBlock listenerMethodBody, JInvocation call, TypeMirror returnType) { boolean returnMethodResult = returnType.getKind() != TypeKind.VOID; if (returnMethodResult) { listenerMethodBody._return(call); } else { listenerMethodBody.add(call); listenerMethodBody._return(JExpr.TRUE); } }