/** * Checks if two classes belong to the same package */ static boolean belongToTheSamePackage(TypeElement class1, TypeElement class2, Elements elements) { Name package1 = elements.getPackageOf(class1).getQualifiedName(); Name package2 = elements.getPackageOf(class2).getQualifiedName(); return package1.equals(package2); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof UngroupedOverloads.OverloadKey) { UngroupedOverloads.OverloadKey that = (UngroupedOverloads.OverloadKey) o; return (this.name.equals(that.name())); } return false; }
/** * Returns a collection of methods with the same name. * * @param methods the methods to process. * @param methodName the method name to findByName. * * @return a collection of methods with the same name. */ private Collection<ExecutableElement> findByName(final Collection<ExecutableElement> methods, final Name methodName) { final List<ExecutableElement> result = new ArrayList<>(); for (ExecutableElement method : methods) { if (methodName.equals(method.getSimpleName())) { result.add(method); } } return result; }
Optional<ClassName> generatedTypeNameOf(TypeElement typeElement) { return graph.entities().stream() .filter(entity -> entity.element().getQualifiedName() .equals(typeElement.getQualifiedName())) .map(this::typeNameOf).findFirst(); }
private Collection<ExecutableElement> findByName(final Collection<ExecutableElement> methods, final ExecutableElement method) { final Name methodName = method.getSimpleName(); final List<ExecutableElement> result = new ArrayList<>(); final int paramCount = parameterCount(method.getParameters()); for (ExecutableElement m : methods) { if (methodName.equals(m.getSimpleName()) && parameterCount(m.getParameters()) == paramCount) { result.add(m); } } return result; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof ParameterTree) { ParameterTree that = (ParameterTree) o; return (this.name.equals(that.getName())) && (this.type.equals(that.getType())) && (this.varArgs == that.isVarArgs()); } return false; }
@Override public void merge(EntityDescriptor from) { from.attributes().forEach(entry -> { // add this attribute if an attribute with the same name is not already existing if (attributes.stream().noneMatch( attribute -> attribute.name().equals(entry.name()))) { attributes.add(new AttributeMember(entry.element(), this)); } }); from.listeners().entrySet().stream() .filter(entry -> entry.getValue() instanceof ListenerMethod) .forEach(entry -> { ListenerMethod method = (ListenerMethod) entry.getValue(); if (listeners.values().stream().noneMatch( listener -> listener.element().getSimpleName() .equals(method.element().getSimpleName()))) { listeners.put(entry.getKey(), method); } }); }
/** * Checks to see if the method is overloaded. An overloaded method has a different parameter count based on the * format parameters only. Parameters annotated with {@link org.jboss.logging.annotations.Cause} or * {@link org.jboss.logging.annotations.Param} * are not counted. * * @param methods the method to search. * @param method the method to check. * * @return {@code true} if the method is overloaded, otherwise {@code false}. */ private boolean isOverloaded(final Collection<ExecutableElement> methods, final ExecutableElement method) { final Collection<ExecutableElement> allMethods = findByName(methods, method.getSimpleName()); for (ExecutableElement m : allMethods) { if (method.getSimpleName().equals(m.getSimpleName()) && parameterCount(method.getParameters()) != parameterCount(m.getParameters())) { return true; } } return false; }
.filter( typeParam -> typeParam.getSimpleName().equals(typeVar.asElement().getSimpleName())) .findFirst()
if (!element.getSimpleName().equals(methodSymbol.getSimpleName())) {
@Override public Choice<Unifier> visitIdentifier(IdentifierTree node, Unifier unifier) { Names names = Names.instance(unifier.getContext()); return node.getName().equals(names._super) ? Choice.<Unifier>none() : defaultAction(node, unifier); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Signature)) { return false; } Signature other = (Signature) obj; return (name.equals(other.name) && params == other.params); } }
protected boolean isOverride(TypeElement typeElement, ExecutableElement methodElement) { TypeElement currentTypeElement = typeElement; do { if (currentTypeElement != typeElement) { List<? extends Element> enclosedElements = currentTypeElement.getEnclosedElements(); for (Element enclosedElement : enclosedElements) { if (enclosedElement.getSimpleName().equals(methodElement.getSimpleName()) && enclosedElement.getAnnotation(Inject.class) != null && enclosedElement.getKind() == ElementKind.METHOD) { return true; } } } TypeMirror superclass = currentTypeElement.getSuperclass(); if (superclass.getKind() == TypeKind.DECLARED) { DeclaredType superType = (DeclaredType) superclass; currentTypeElement = (TypeElement) superType.asElement(); } else { currentTypeElement = null; } } while (currentTypeElement != null); return false; }
if (currentMethod.getName().equals(method.name)) { MethodSymbol currentMethodSymbol = ASTHelpers.getSymbol(currentMethod); if (currentMethodSymbol.overrides(
@Override public boolean equals(Object obj) { if (!(obj instanceof Signature)) { return false; } Signature other = (Signature) obj; return (name.equals(other.name) && params == other.params); } }
/** * Remove member declarations with the specified name, if it exists.. * * @param name The member to remove. */ public void removeByName(Name name) { removeIf(e -> e.getSimpleName().equals(name)); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (obj instanceof TypeElement) { return getQualifiedName().equals(((TypeElement) obj).getQualifiedName()); } return false; }
private SubResource findRecursiveSubResource(TypeElement declaration, String path) { LinkedList<SubResource> ancestorResources = SubResource.ANCESTOR_DECLARATIONS.get(); for (SubResource ancestorResource : ancestorResources) { if (ancestorResource.getQualifiedName().equals(declaration.getQualifiedName()) && ancestorResource.getPath().equals(path)) { return ancestorResource; } } return null; }
/** * A quick check to see if a declaration is an endpoint implementation. */ protected boolean isEndpointImplementation(TypeElement declaration) { if (declaration.getKind() == ElementKind.CLASS && !declaration.getQualifiedName().equals(getQualifiedName())) { WebService webServiceInfo = declaration.getAnnotation(WebService.class); return webServiceInfo != null && getQualifiedName().toString().equals(webServiceInfo.endpointInterface()); } return false; }
@Override public Choice<Unifier> visitIdentifier(IdentifierTree node, Unifier unifier) { Names names = Names.instance(unifier.getContext()); return node.getName().equals(names._super) ? Choice.<Unifier>none() : defaultAction(node, unifier); }