@Override public boolean equals(Object obj) { return delegate.equals(obj); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Root root = (Root) o; if (isMethodReceiver != root.isMethodReceiver) { return false; } return varElement != null ? varElement.equals(root.varElement) : root.varElement == null; }
@Override public boolean equals(Object obj) { if (obj instanceof ProcessableElement) { ProcessableElement other = (ProcessableElement) obj; return element.equals(other.element()); } return false; }
@Override public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment roundEnv ) { for ( TypeElement type : annotations ) { for ( Element annotated : roundEnv.getElementsAnnotatedWith( type ) ) { for ( AnnotationMirror mirror : annotated.getAnnotationMirrors() ) { if ( mirror.getAnnotationType().asElement().equals( type ) ) { try { process( type, annotated, mirror, processingEnv.getElementUtils() .getElementValuesWithDefaults( mirror ) ); } catch ( Exception e ) { e.printStackTrace(); processingEnv.getMessager().printMessage( Kind.ERROR, "Internal error: " + e, annotated, mirror ); } } } } } return false; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof AccessPath) { AccessPath that = (AccessPath) o; return ((this.base == null) ? (that.base() == null) : this.base.equals(that.base())) && (this.path.equals(that.path())); } return false; }
private static boolean isNested(Object innerUserObject, Object outerUserObject) { if (innerUserObject instanceof Method) { Class<?> cls = ((Method) innerUserObject).getDeclaringClass(); if (cls.equals(outerUserObject) || cls.equals(outerUserObject.getClass())) { return true; } } else if (innerUserObject instanceof Element) { // ExecutableElement or TypeElement Element enclosingElement = ((Element) innerUserObject).getEnclosingElement(); while (enclosingElement != null) { if (enclosingElement.equals(outerUserObject)) { return true; } enclosingElement = enclosingElement.getEnclosingElement(); } return false; } else if (innerUserObject instanceof Class) { Class<?> cls = (Class<?>) innerUserObject; if (cls.isMemberClass() && (cls.getEnclosingClass().equals(outerUserObject) || cls.getEnclosingClass().equals(outerUserObject.getClass()))) { return true; } } else { Class<?> cls = innerUserObject.getClass(); if (cls.isMemberClass() && (cls.getEnclosingClass().equals(outerUserObject) || cls.getEnclosingClass().equals(outerUserObject.getClass()))) { return true; } } return false; }
public static boolean equals(Element left, Element right) { return getDelegate(left).equals(getDelegate(right)); }
.forEach(getter -> names.addAll(map.entrySet().stream() .filter(entry -> entry.getKey().equals(getter)) .map(entry -> entry.getValue().fieldName()) .collect(Collectors.toList())));
public void uniqueResourceId(Element element, Res resourceType, ElementValidation valid) { if (valid.isValid()) { List<String> annotationQualifiedIds = idAnnotationHelper.extractAnnotationResources(element, resourceType, true); Element elementEnclosingElement = element.getEnclosingElement(); Set<? extends Element> annotatedElements = validatedModel().getRootAnnotatedElements(annotationHelper.getTarget()); for (Element uniqueCheckElement : annotatedElements) { Element uniqueCheckEnclosingElement = uniqueCheckElement.getEnclosingElement(); if (elementEnclosingElement.equals(uniqueCheckEnclosingElement)) { List<String> checkQualifiedIds = idAnnotationHelper.extractAnnotationResources(uniqueCheckElement, resourceType, true); for (String checkQualifiedId : checkQualifiedIds) { for (String annotationQualifiedId : annotationQualifiedIds) { if (annotationQualifiedId.equals(checkQualifiedId)) { String annotationSimpleId = annotationQualifiedId.substring(annotationQualifiedId.lastIndexOf('.') + 1); valid.addError("The resource id " + annotationSimpleId + " is already used on the following " + annotationHelper.annotationName() + " method: " + uniqueCheckElement); return; } } } } } } }
&& !javaLang.equals(imp.getEnclosingElement())) { imports.add(imp.getQualifiedName().toString());
if (declaredType.asElement().getKind() == ENUM && !element.equals(declaredType.asElement())) { debugElement(declaredType.asElement(), indent + " --> ");
/** * Log an error to this model spec. * * This is generally intended for logging things like validation errors. Such errors do not stop the code * generation process (as logging an error using Messager and Kind.ERROR would), but instead generate * temporary code in the model class that will be picked up by a subsequent annotation processor and logged as * errors in a later round of annotation processing. This mechanism is designed to work around the fact that * logging Kind.ERROR messages during early rounds of annotation processing may suppress those errors, because * failing early during annotation processing can lead to a large number of "symbol not found" errors, which in * turn mask other validation errors. * <p> * If {@link PluginEnvironment#OPTIONS_USE_STANDARD_ERROR_LOGGING} is passed as an option to the code generator, * this SquiDB workaround is disabled and this method will log an error using a standard printMessage() call with * Kind.ERROR. * * @param message the error message to be logged * @param element the specific inner element in the model spec that is causing this error (e.g. a field or method), * or null for a general error */ public void logError(String message, Element element) { if (pluginEnvironment.hasSquidbOption(PluginEnvironment.OPTIONS_USE_STANDARD_ERROR_LOGGING)) { utils.getMessager().printMessage(Diagnostic.Kind.ERROR, message, element); } else { boolean isRootElement = element == null || element.equals(getModelSpecElement()); loggedErrors.add(new ErrorInfo(getModelSpecName(), isRootElement ? "" : element.getSimpleName().toString(), message)); } }
target = ValueToBuilderTarget.BUILDER_CONSTRUCTOR; } else if (copyMethod.getModifiers().contains(Modifier.STATIC)) { if (copyMethod.getEnclosingElement().equals(attributeValueType())) { target = ValueToBuilderTarget.VALUE_TYPE; } else { if (copyMethod.getEnclosingElement().equals(attributeValueType())) { target = ValueToBuilderTarget.VALUE_INSTANCE; } else { if (builderMethod.getEnclosingElement().equals(attributeValueType())) { qualifiedBuilderConstructorMethod = String.format("%s.%s", attributeValueType().getQualifiedName(),
if (varElement.equals(fromVar.getElement())) { LocalVariableNode toVar = localVarTranslations.get(fromVar); AccessPath newAP =
if (attributeMethodCandidate.getEnclosingElement().equals(originalType)) { hasNonInheritedAttributes = true;
private TypeMirror onDeclaredType(DeclaredType t, TypeElement sup) { // t = sup<...> if (t.asElement().equals(sup)) return t; for (TypeMirror i : env.getTypeUtils().directSupertypes(t)) { TypeMirror r = visitDeclared((DeclaredType) i, sup); if (r != null) return r; } return null; }
private boolean isSingleInjectAnnotatedConstructor(Element constructorElement) { TypeElement enclosingElement = (TypeElement) constructorElement.getEnclosingElement(); boolean isSingleInjectedConstructor = true; List<ExecutableElement> constructorElements = ElementFilter.constructorsIn(enclosingElement.getEnclosedElements()); for (ExecutableElement constructorElementInClass : constructorElements) { if (constructorElementInClass.getAnnotation(Inject.class) != null && !constructorElement.equals(constructorElementInClass)) { isSingleInjectedConstructor = false; } } return isSingleInjectedConstructor; }
private boolean hasServiceLocator(TypeElement x, State state) { Service service = x.getAnnotation(Service.class); if (service != null) { // See javadoc on getAnnotation try { service.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.serviceLocatorType.asElement()); } } ServiceName serviceName = x.getAnnotation(ServiceName.class); return serviceName != null && !serviceName.locator().isEmpty(); }
private boolean hasProxyLocator(TypeElement x, State state) { ProxyFor proxyFor = x.getAnnotation(ProxyFor.class); if (proxyFor != null) { // See javadoc on getAnnotation try { proxyFor.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.locatorType.asElement()); } } ProxyForName proxyForName = x.getAnnotation(ProxyForName.class); return proxyForName != null && !proxyForName.locator().isEmpty(); }
/** * Verifies {@code method} is an abstract getter. Any deviations will be logged as an error. */ private boolean methodIsAbstractGetter(TypeElement valueType, ExecutableElement method) { Set<Modifier> modifiers = method.getModifiers(); if (!modifiers.contains(Modifier.ABSTRACT)) { return false; } boolean declaredOnValueType = method.getEnclosingElement().equals(valueType); TypeMirror returnType = getReturnType(valueType, method, types); if (returnType.getKind() == TypeKind.VOID || !method.getParameters().isEmpty()) { if (declaredOnValueType) { messager.printMessage( ERROR, "Only getter methods may be declared abstract on FreeBuilder types", method); } else { printNoImplementationMessage(valueType, method); } return false; } return true; }