Java Code Examples for javax.lang.model.element.TypeElement#getModifiers()
The following examples show how to use
javax.lang.model.element.TypeElement#getModifiers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassEntity.java From RxPay with Apache License 2.0 | 6 votes |
/** * @param elementUtils * @param typeUtils * @param element current anntated class */ public ClassEntity(Elements elementUtils, Types typeUtils, TypeElement element) { elementWeakCache = new WeakReference<TypeElement>(element); this.classPackageName = elementUtils.getPackageOf(element).getQualifiedName().toString(); this.modifierSet = element.getModifiers(); this.className = element.toString(); annotationMirrors = element.getAnnotationMirrors(); this.classSimpleName = element.getSimpleName(); this.classQualifiedName = element.getQualifiedName(); if ("java.lang.Object".equals(element.getSuperclass().toString())){ this.superclass = null; }else{ this.superclass = element.getSuperclass().toString(); } List<? extends TypeMirror> interfaces = element.getInterfaces(); for (TypeMirror anInterface : interfaces){ this.interfaces.add(typeUtils.asElement(anInterface).toString()); } }
Example 2
Source File: ManagedBeansAnalizer.java From netbeans with Apache License 2.0 | 6 votes |
private void checkAbstract( TypeElement element, WebBeansModel model, Result result ) { Set<Modifier> modifiers = element.getModifiers(); if ( modifiers.contains( Modifier.ABSTRACT )){ if ( AnnotationUtil.hasAnnotation(element, AnnotationUtil.DECORATOR, model.getCompilationController()) ){ return; } // element is abstract and has no Decorator annotation result.addNotification( Severity.WARNING, element, model, NbBundle.getMessage(ManagedBeansAnalizer.class, "WARN_QualifierAbstractClass")); // NOI18N } }
Example 3
Source File: PubapiVisitor.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override @DefinedBy(Api.LANGUAGE_MODEL) public Void visitType(TypeElement e, Void p) { if (isNonPrivate(e)) { PubApi prevApi = collectedApi; collectedApi = new PubApi(); super.visitType(e, p); if (!isAnonymous(e)) { String name = ((ClassSymbol) e).flatname.toString(); PubType t = new PubType(e.getModifiers(), name, //e.getQualifiedName().toString(), collectedApi); prevApi.types.put(t.fqName, t); } collectedApi = prevApi; } return null; }
Example 4
Source File: FactoryProcessor.java From toothpick with Apache License 2.0 | 5 votes |
private boolean isValidInjectAnnotatedConstructor(ExecutableElement element) { TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify modifiers. Set<Modifier> modifiers = element.getModifiers(); if (modifiers.contains(PRIVATE)) { error( element, "@Inject constructors must not be private in class %s.", enclosingElement.getQualifiedName()); return false; } // Verify parentScope modifiers. Set<Modifier> parentModifiers = enclosingElement.getModifiers(); if (parentModifiers.contains(PRIVATE)) { error( element, "Class %s is private. @Inject constructors are not allowed in private classes.", enclosingElement.getQualifiedName()); return false; } if (isNonStaticInnerClass(enclosingElement)) { return false; } for (VariableElement paramElement : element.getParameters()) { if (!isValidInjectedType(paramElement)) { return false; } } return true; }
Example 5
Source File: ResolverProcessor.java From AndServer with Apache License 2.0 | 5 votes |
private Map<String, TypeElement> findAnnotation(RoundEnvironment roundEnv) { Set<? extends Element> set = roundEnv.getElementsAnnotatedWith(Resolver.class); Map<String, TypeElement> resolverMap = new HashMap<>(); for (Element element : set) { if (element instanceof TypeElement) { TypeElement typeElement = (TypeElement) element; Set<Modifier> modifiers = typeElement.getModifiers(); Validate.isTrue(modifiers.contains(Modifier.PUBLIC), "The modifier public is missing on %s.", typeElement.getQualifiedName()); List<? extends TypeMirror> interfaces = typeElement.getInterfaces(); if (CollectionUtils.isEmpty(interfaces)) { mLog.w(String.format( "The annotation Resolver must be used in a subclass of [ExceptionResolver] on %s.", typeElement.getQualifiedName())); continue; } for (TypeMirror typeMirror : interfaces) { if (mResolver.equals(TypeName.get(typeMirror))) { resolverMap.put(getGroup(typeElement), typeElement); break; } else { mLog.w(String.format( "The annotation Resolver must be used in a subclass of [ExceptionResolver] on %s.", typeElement.getQualifiedName())); } } } } return resolverMap; }
Example 6
Source File: JFactoryMethodCodeGenerator.java From jackdaw with Apache License 2.0 | 5 votes |
@Override protected final void generateBody( final CodeGeneratorContext context, final TypeSpec.Builder builder ) { final TypeElement typeElement = context.getTypeElement(); final JFactoryMethod annotation = typeElement.getAnnotation(JFactoryMethod.class); final Set<Modifier> modifiers = typeElement.getModifiers(); final ElementKind kind = typeElement.getKind(); if (annotation != null && kind == ElementKind.CLASS && !modifiers.contains(Modifier.ABSTRACT)) { generateFactoryMethod(builder, typeElement, annotation); } }
Example 7
Source File: Validator.java From AutoBundle with Apache License 2.0 | 5 votes |
static void checkAutoBundleTargetModifier(TypeElement typeElement) { Set<Modifier> modifiers = typeElement.getModifiers(); if (modifiers.contains(Modifier.ABSTRACT)) { throw new ProcessingException( "AutoBundle must be with concrete class."); } else if (typeElement.getModifiers().contains(Modifier.PRIVATE) || modifiers.contains(Modifier.PROTECTED)) { throw new ProcessingException( "AutoBundle must not be with private/protected class."); } }
Example 8
Source File: InterceptorProcessor.java From AndServer with Apache License 2.0 | 5 votes |
private Map<String, List<TypeElement>> findAnnotation(RoundEnvironment roundEnv) { Set<? extends Element> set = roundEnv.getElementsAnnotatedWith(Interceptor.class); Map<String, List<TypeElement>> interceptorMap = new HashMap<>(); for (Element element : set) { if (element instanceof TypeElement) { TypeElement typeElement = (TypeElement) element; Set<Modifier> modifiers = typeElement.getModifiers(); Validate.isTrue(modifiers.contains(Modifier.PUBLIC), "The modifier public is missing on %s.", typeElement.getQualifiedName()); List<? extends TypeMirror> interfaces = typeElement.getInterfaces(); if (CollectionUtils.isEmpty(interfaces)) { mLog.w(String.format( "The annotation Interceptor must be used in a subclass of [HandlerInterceptor] on %s.", typeElement.getQualifiedName())); continue; } for (TypeMirror typeMirror : interfaces) { if (mInterceptor.equals(TypeName.get(typeMirror))) { String group = getGroup(typeElement); List<TypeElement> elementList = interceptorMap.get(group); if (CollectionUtils.isEmpty(elementList)) { elementList = new ArrayList<>(); interceptorMap.put(group, elementList); } elementList.add(typeElement); break; } else { mLog.w(String.format( "The annotation Interceptor must be used in a subclass of [HandlerInterceptor] on %s.", typeElement.getQualifiedName())); } } } } return interceptorMap; }
Example 9
Source File: ManagedBeansAnalizer.java From netbeans with Apache License 2.0 | 5 votes |
private void checkInner( TypeElement element, TypeElement parent, WebBeansModel model, Result result ) { if ( parent == null ){ return; } Set<Modifier> modifiers = element.getModifiers(); if ( !modifiers.contains( Modifier.STATIC )){ result.addError(element, model, NbBundle.getMessage(ManagedBeansAnalizer.class, "ERR_NonStaticInnerType")); // NOI18N } }
Example 10
Source File: EntityMetaFactory.java From doma with Apache License 2.0 | 5 votes |
void validateEnclosingElement(Element element) { TypeElement typeElement = ctx.getMoreElements().toTypeElement(element); if (typeElement == null) { return; } String simpleName = typeElement.getSimpleName().toString(); if (simpleName.contains(Constants.BINARY_NAME_DELIMITER) || simpleName.contains(Constants.TYPE_NAME_DELIMITER)) { throw new AptException( Message.DOMA4317, typeElement, new Object[] {typeElement.getQualifiedName()}); } NestingKind nestingKind = typeElement.getNestingKind(); if (nestingKind == NestingKind.TOP_LEVEL) { return; } else if (nestingKind == NestingKind.MEMBER) { Set<Modifier> modifiers = typeElement.getModifiers(); if (modifiers.containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))) { validateEnclosingElement(typeElement.getEnclosingElement()); } else { throw new AptException( Message.DOMA4315, typeElement, new Object[] {typeElement.getQualifiedName()}); } } else { throw new AptException( Message.DOMA4316, typeElement, new Object[] {typeElement.getQualifiedName()}); } }
Example 11
Source File: ToothpickProcessor.java From toothpick with Apache License 2.0 | 5 votes |
protected boolean isValidInjectAnnotatedFieldOrParameter(VariableElement variableElement) { TypeElement enclosingElement = (TypeElement) variableElement.getEnclosingElement(); // Verify modifiers. Set<Modifier> modifiers = variableElement.getModifiers(); if (modifiers.contains(PRIVATE)) { error( variableElement, "@Inject annotated fields must be non private : %s#%s", enclosingElement.getQualifiedName(), variableElement.getSimpleName()); return false; } // Verify parentScope modifiers. Set<Modifier> parentModifiers = enclosingElement.getModifiers(); if (parentModifiers.contains(PRIVATE)) { error( variableElement, "@Injected fields in class %s. The class must be non private.", enclosingElement.getSimpleName()); return false; } if (!isValidInjectedType(variableElement)) { return false; } return true; }
Example 12
Source File: InterceptedBeanAnalyzer.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void analyze( TypeElement element, TypeElement parent, WebBeansModel model, AtomicBoolean cancel, Result result ) { if ( AnnotationUtil.hasAnnotation(element, AnnotationUtil.INTERCEPTOR, model.getCompilationController() )) { result.requireCdiEnabled(element, model); // rule should not be applied to interceptor return ; } boolean hasIBindings = hasInterceptorBindings(element, model); if ( hasIBindings ){ result.requireCdiEnabled(element, model); EditorAnnotationsHelper helper = EditorAnnotationsHelper.getInstance(result); ElementHandle<TypeElement> handle = ElementHandle.create(element); if ( helper != null ){ helper.addInterceptedBean( result , handle.resolve( result.getInfo())); } } Set<Modifier> modifiers = element.getModifiers(); boolean isFinal = modifiers.contains(Modifier.FINAL); List<ExecutableElement> methods = ElementFilter.methodsIn( element.getEnclosedElements()); ExecutableElement badMethod = null; for (ExecutableElement method : methods) { if ( cancel.get() ){ return; } modifiers = method.getModifiers(); if ( !modifiers.contains( Modifier.FINAL )){ continue; } if ( modifiers.contains( Modifier.STATIC ) || modifiers.contains( Modifier.PRIVATE)) { continue; } badMethod = method; break; } if ( badMethod == null && !isFinal ){ return; } if ( cancel.get() ){ return; } if (hasIBindings && isFinal) { result.addError(element, model, NbBundle.getMessage( InterceptedBeanAnalyzer.class, "ERR_FinalInterceptedBean")); // NOI18N } if (hasIBindings && badMethod != null) { result.addError(element, model, NbBundle.getMessage( InterceptedBeanAnalyzer.class, "ERR_InterceptedBeanHasFinalMethod", badMethod .getSimpleName().toString())); // NOI18N } }
Example 13
Source File: EnableBeansFilter.java From netbeans with Apache License 2.0 | 4 votes |
private boolean checkClass( TypeElement element ){ if ( element.getKind() != ElementKind.CLASS ){ return false; } Set<Modifier> modifiers = element.getModifiers(); Element enclosing = element.getEnclosingElement(); if ( !( enclosing instanceof PackageElement) ){ /* * If class is inner class then it should be static. */ if ( !modifiers.contains( Modifier.STATIC ) ){ return false; } } Elements elements = getHelper().getCompilationController().getElements(); Types types = getHelper().getCompilationController().getTypes(); List<? extends AnnotationMirror> allAnnotations = elements. getAllAnnotationMirrors(element); if ( modifiers.contains( Modifier.ABSTRACT ) && !getHelper().hasAnnotation(allAnnotations, DECORATOR ) ) { /* * If class is abstract it should be Decorator. */ return false; } TypeElement extensionElement = elements.getTypeElement( EXTENSION ); if ( extensionElement!= null ){ TypeMirror extensionType = extensionElement.asType(); /* * Class doesn't implement Extension */ if ( types.isAssignable( element.asType(), extensionType )){ return false; } } /* * There should be either no parameters CTOR or CTOR is annotated with @Inject */ List<ExecutableElement> constructors = ElementFilter.constructorsIn( element.getEnclosedElements()); boolean foundCtor = constructors.size() ==0; for (ExecutableElement ctor : constructors) { if ( ctor.getParameters().size() == 0 ){ foundCtor = true; break; } if ( getHelper().hasAnnotation(allAnnotations, FieldInjectionPointLogic.INJECT_ANNOTATION)) { foundCtor = true; break; } } return foundCtor; }
Example 14
Source File: WebServiceVisitor.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
protected boolean isLegalImplementation(WebService webService, TypeElement classElement) { boolean isStateful = isStateful(classElement); Collection<Modifier> modifiers = classElement.getModifiers(); if (!modifiers.contains(Modifier.PUBLIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_NOT_PUBLIC(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.FINAL) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_FINAL(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.ABSTRACT) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_ABSTRACT(classElement.getQualifiedName()), classElement); return false; } boolean hasDefaultConstructor = false; for (ExecutableElement constructor : ElementFilter.constructorsIn(classElement.getEnclosedElements())) { if (constructor.getModifiers().contains(Modifier.PUBLIC) && constructor.getParameters().isEmpty()) { hasDefaultConstructor = true; break; } } if (!hasDefaultConstructor && !isStateful) { if (classElement.getEnclosingElement() != null && !modifiers.contains(Modifier.STATIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_INNERCLASS_NOT_STATIC( classElement.getQualifiedName()), classElement); return false; } builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_NO_DEFAULT_CONSTRUCTOR( classElement.getQualifiedName()), classElement); return false; } if (webService.endpointInterface().isEmpty()) { if (!methodsAreLegal(classElement)) return false; } else { TypeElement interfaceElement = getEndpointInterfaceElement(webService.endpointInterface(), classElement); if (!classImplementsSei(classElement, interfaceElement)) return false; } return true; }
Example 15
Source File: GraphNodeProcessor.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } GraphNodeVerifier verifier = new GraphNodeVerifier(this); for (Element element : roundEnv.getElementsAnnotatedWith(NodeInfo.class)) { scope = element; try { if (!isNodeType(element)) { errorMessage(element, "%s can only be applied to Node subclasses", NodeInfo.class.getSimpleName()); continue; } NodeInfo nodeInfo = element.getAnnotation(NodeInfo.class); if (nodeInfo == null) { errorMessage(element, "Cannot get %s annotation from annotated element", NodeInfo.class.getSimpleName()); continue; } TypeElement typeElement = (TypeElement) element; Set<Modifier> modifiers = typeElement.getModifiers(); if (!modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.ABSTRACT)) { // TODO(thomaswue): Reenable this check. // errorMessage(element, "%s annotated class must be either final or abstract", // NodeInfo.class.getSimpleName()); // continue; } boolean found = false; for (Element e : typeElement.getEnclosedElements()) { if (e.getKind() == ElementKind.FIELD) { if (e.getSimpleName().toString().equals("TYPE")) { found = true; break; } } } if (!found) { errorMessage(element, "%s annotated class must have a field named TYPE", NodeInfo.class.getSimpleName()); } if (!typeElement.equals(verifier.Node) && !modifiers.contains(Modifier.ABSTRACT)) { verifier.verify(typeElement); } } catch (ElementException ee) { errorMessage(ee.element, ee.getMessage()); } catch (Throwable t) { reportException(isBug367599(t) ? Kind.NOTE : Kind.ERROR, element, t); } finally { scope = null; } } return false; }
Example 16
Source File: WebServiceVisitor.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
protected boolean isLegalImplementation(WebService webService, TypeElement classElement) { boolean isStateful = isStateful(classElement); Collection<Modifier> modifiers = classElement.getModifiers(); if (!modifiers.contains(Modifier.PUBLIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_NOT_PUBLIC(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.FINAL) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_FINAL(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.ABSTRACT) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_ABSTRACT(classElement.getQualifiedName()), classElement); return false; } boolean hasDefaultConstructor = false; for (ExecutableElement constructor : ElementFilter.constructorsIn(classElement.getEnclosedElements())) { if (constructor.getModifiers().contains(Modifier.PUBLIC) && constructor.getParameters().isEmpty()) { hasDefaultConstructor = true; break; } } if (!hasDefaultConstructor && !isStateful) { if (classElement.getEnclosingElement() != null && !modifiers.contains(Modifier.STATIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_INNERCLASS_NOT_STATIC( classElement.getQualifiedName()), classElement); return false; } builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_NO_DEFAULT_CONSTRUCTOR( classElement.getQualifiedName()), classElement); return false; } if (webService.endpointInterface().isEmpty()) { if (!methodsAreLegal(classElement)) return false; } else { TypeElement interfaceElement = getEndpointInterfaceElement(webService.endpointInterface(), classElement); if (!classImplementsSei(classElement, interfaceElement)) return false; } return true; }
Example 17
Source File: WebServiceVisitor.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
protected boolean isLegalImplementation(WebService webService, TypeElement classElement) { boolean isStateful = isStateful(classElement); Collection<Modifier> modifiers = classElement.getModifiers(); if (!modifiers.contains(Modifier.PUBLIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_NOT_PUBLIC(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.FINAL) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_FINAL(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.ABSTRACT) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_ABSTRACT(classElement.getQualifiedName()), classElement); return false; } boolean hasDefaultConstructor = false; for (ExecutableElement constructor : ElementFilter.constructorsIn(classElement.getEnclosedElements())) { if (constructor.getModifiers().contains(Modifier.PUBLIC) && constructor.getParameters().isEmpty()) { hasDefaultConstructor = true; break; } } if (!hasDefaultConstructor && !isStateful) { if (classElement.getEnclosingElement() != null && !modifiers.contains(Modifier.STATIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_INNERCLASS_NOT_STATIC( classElement.getQualifiedName()), classElement); return false; } builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_NO_DEFAULT_CONSTRUCTOR( classElement.getQualifiedName()), classElement); return false; } if (webService.endpointInterface().isEmpty()) { if (!methodsAreLegal(classElement)) return false; } else { TypeElement interfaceElement = getEndpointInterfaceElement(webService.endpointInterface(), classElement); if (!classImplementsSei(classElement, interfaceElement)) return false; } return true; }
Example 18
Source File: WebServiceVisitor.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
protected boolean isLegalImplementation(WebService webService, TypeElement classElement) { boolean isStateful = isStateful(classElement); Collection<Modifier> modifiers = classElement.getModifiers(); if (!modifiers.contains(Modifier.PUBLIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_NOT_PUBLIC(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.FINAL) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_FINAL(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.ABSTRACT) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_ABSTRACT(classElement.getQualifiedName()), classElement); return false; } boolean hasDefaultConstructor = false; for (ExecutableElement constructor : ElementFilter.constructorsIn(classElement.getEnclosedElements())) { if (constructor.getModifiers().contains(Modifier.PUBLIC) && constructor.getParameters().isEmpty()) { hasDefaultConstructor = true; break; } } if (!hasDefaultConstructor && !isStateful) { if (classElement.getEnclosingElement() != null && !modifiers.contains(Modifier.STATIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_INNERCLASS_NOT_STATIC( classElement.getQualifiedName()), classElement); return false; } builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_NO_DEFAULT_CONSTRUCTOR( classElement.getQualifiedName()), classElement); return false; } if (webService.endpointInterface().isEmpty()) { if (!methodsAreLegal(classElement)) return false; } else { TypeElement interfaceElement = getEndpointInterfaceElement(webService.endpointInterface(), classElement); if (!classImplementsSei(classElement, interfaceElement)) return false; } return true; }
Example 19
Source File: ToothpickProcessor.java From toothpick with Apache License 2.0 | 4 votes |
protected boolean isValidInjectAnnotatedMethod(ExecutableElement methodElement) { TypeElement enclosingElement = (TypeElement) methodElement.getEnclosingElement(); // Verify modifiers. Set<Modifier> modifiers = methodElement.getModifiers(); if (modifiers.contains(PRIVATE)) { error( methodElement, "@Inject annotated methods must not be private : %s#%s", enclosingElement.getQualifiedName(), methodElement.getSimpleName()); return false; } // Verify parentScope modifiers. Set<Modifier> parentModifiers = enclosingElement.getModifiers(); if (parentModifiers.contains(PRIVATE)) { error( methodElement, "@Injected fields in class %s. The class must be non private.", enclosingElement.getSimpleName()); return false; } for (VariableElement paramElement : methodElement.getParameters()) { if (!isValidInjectedType(paramElement)) { return false; } } if (modifiers.contains(PUBLIC) || modifiers.contains(PROTECTED)) { if (!hasWarningSuppressed(methodElement, SUPPRESS_WARNING_ANNOTATION_VISIBLE_VALUE)) { crashOrWarnWhenMethodIsNotPackageVisible( methodElement, format( "@Inject annotated methods should have package visibility: %s#%s", // enclosingElement.getQualifiedName(), methodElement.getSimpleName())); } } return true; }
Example 20
Source File: WebServiceVisitor.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
protected boolean isLegalImplementation(WebService webService, TypeElement classElement) { boolean isStateful = isStateful(classElement); Collection<Modifier> modifiers = classElement.getModifiers(); if (!modifiers.contains(Modifier.PUBLIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_NOT_PUBLIC(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.FINAL) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_FINAL(classElement.getQualifiedName()), classElement); return false; } if (modifiers.contains(Modifier.ABSTRACT) && !isStateful) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_ABSTRACT(classElement.getQualifiedName()), classElement); return false; } boolean hasDefaultConstructor = false; for (ExecutableElement constructor : ElementFilter.constructorsIn(classElement.getEnclosedElements())) { if (constructor.getModifiers().contains(Modifier.PUBLIC) && constructor.getParameters().isEmpty()) { hasDefaultConstructor = true; break; } } if (!hasDefaultConstructor && !isStateful) { if (classElement.getEnclosingElement() != null && !modifiers.contains(Modifier.STATIC)) { builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_CLASS_IS_INNERCLASS_NOT_STATIC( classElement.getQualifiedName()), classElement); return false; } builder.processError(WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_NO_DEFAULT_CONSTRUCTOR( classElement.getQualifiedName()), classElement); return false; } if (webService.endpointInterface().isEmpty()) { if (!methodsAreLegal(classElement)) return false; } else { TypeElement interfaceElement = getEndpointInterfaceElement(webService.endpointInterface(), classElement); if (!classImplementsSei(classElement, interfaceElement)) return false; } return true; }