Package javax.lang.model.element

Examples of javax.lang.model.element.Name


                        bootstrapOperations.add(op);
                    }


                } else if (element.getAnnotation(NoGatekeeper.class) == null) {
                    Name simpleName = element.getEnclosingElement() != null ? element.getEnclosingElement()
                            .getSimpleName() : element.getSimpleName();
                    System.out.println(
                            simpleName + "(#" + nameToken.value()[0] + ")" + " is missing @AccessControl annotation!");
                }
            }
View Full Code Here


     */
    public boolean isAnnotatedWith(String annotationTypeName) {
        List<? extends AnnotationMirror> annotationMirrors = typeElement.getAnnotationMirrors();

        for ( AnnotationMirror mirror : annotationMirrors ) {
            Name mirrorAnnotationName = ( (TypeElement) mirror.getAnnotationType().asElement() ).getQualifiedName();
            if ( mirrorAnnotationName.contentEquals( annotationTypeName ) ) {
                return true;
            }
        }

        return false;
View Full Code Here

  FactoryMethodDescriptor generateDescriptorForConstructor(final AutoFactoryDeclaration declaration,
      ExecutableElement constructor) {
    checkNotNull(constructor);
    checkArgument(constructor.getKind() == ElementKind.CONSTRUCTOR);
    Element classElement = constructor.getEnclosingElement();
    Name returnType = classElement.accept(
        new ElementKindVisitor6<Name, Void>() {
          @Override
          protected Name defaultAction(Element e, Void p) {
            throw new AssertionError();
          }

          @Override
          public Name visitTypeAsClass(TypeElement e, Void p) {
            if (!e.getTypeParameters().isEmpty()) {
              messager.printMessage(ERROR, "AutoFactory does not support generic types", e);
            }
            return e.getQualifiedName();
          }
        }, null);
    ImmutableListMultimap<Boolean, ? extends VariableElement> parameterMap =
        Multimaps.index(constructor.getParameters(), Functions.forPredicate(
            new Predicate<VariableElement>() {
              @Override
              public boolean apply(VariableElement parameter) {
                return parameter.getAnnotation(Provided.class) != null;
              }
            }));
    ImmutableSet<Parameter> providedParameters = Parameter.forParameterList(parameterMap.get(true));
    ImmutableSet<Parameter> passedParameters = Parameter.forParameterList(parameterMap.get(false));
    return new FactoryMethodDescriptor.Builder(declaration)
        .factoryName(declaration.getFactoryName(
            elements.getPackageOf(constructor).getQualifiedName(), classElement.getSimpleName()))
        .name("create")
        .returnType(returnType.toString())
        .publicMethod(constructor.getEnclosingElement().getModifiers().contains(PUBLIC))
        .providedParameters(providedParameters)
        .passedParameters(passedParameters)
        .creationParameters(Parameter.forParameterList(constructor.getParameters()))
        .build();
View Full Code Here

    return getAnnotation(target, annotationQualifiedName) != null;
  }

  public static AnnotationMirror getAnnotation(Element target, CharSequence annotationQualifiedName) {
    for (AnnotationMirror am : target.getAnnotationMirrors()) {
      Name annotationClassName = ((TypeElement) am.getAnnotationType().asElement()).getQualifiedName();
      if (annotationClassName.contentEquals(annotationQualifiedName)) {
        return am;
      }
    }
    return null;
  }
View Full Code Here

   * @return the property name defined by the method according to JavaBeans
   *         convention, or null if the method does not define a JavaBeans
   *         property setter/getter.
   */
  static String propertyNameOfMethod(Element el) {
    Name methodName = el.getSimpleName();
    String propertyName = null;
    if (methodName.length() > 3 && "get".contentEquals(methodName.subSequence(0, 3))) {
      StringBuilder sb = new StringBuilder(methodName.length() - 3);
      sb.append(Character.toLowerCase(methodName.charAt(3)));
      sb.append(methodName.subSequence(4, methodName.length()));
      propertyName = sb.toString();
    }
    else if (methodName.length() > 2 && "is".contentEquals(methodName.subSequence(0, 2))) {
      StringBuilder sb = new StringBuilder(methodName.length() - 2);
      sb.append(Character.toLowerCase(methodName.charAt(2)));
      sb.append(methodName.subSequence(3, methodName.length()));
      propertyName = sb.toString();
    }
    else if (methodName.length() > 3 && "set".contentEquals(methodName.subSequence(0, 2))) {
      StringBuilder sb = new StringBuilder(methodName.length() - 3);
      sb.append(Character.toLowerCase(methodName.charAt(3)));
      sb.append(methodName.subSequence(4, methodName.length()));
      propertyName = sb.toString();
    }
    return propertyName;
  }
View Full Code Here

                        accessControlDeclararions.add(declared);
                    }
                }
                else if(element.getAnnotation(NoGatekeeper.class)==null)
                {
                    Name simpleName = element.getEnclosingElement()!=null ? element.getEnclosingElement().getSimpleName() : element.getSimpleName();
                    System.out.println(simpleName +"(#"+nameToken.value()+")" +" is missing @AccessControl annotation!");
                }
            }
        }
    }
View Full Code Here

            return false;
        }
    }

    private static AnnotationMirror findAnnotationMirror(Element target, TypeElement annotationType) {
        final Name annotationTypeName = annotationType.getQualifiedName();
        for (AnnotationMirror am : target.getAnnotationMirrors()) {
            if (GenerationUtil.getQualifiedName(am).contentEquals(annotationTypeName)) {
                return am;
            }
        }
View Full Code Here

   *
   * @return The given mirror's annotation type.
   */
  public AnnotationType getAnnotationType(AnnotationMirror annotationMirror) {

    Name key = getName( annotationMirror.getAnnotationType() );

    AnnotationType annotationType = annotationTypeCache.get( key );

    if ( annotationType != null ) {
      return annotationType;
View Full Code Here

   *
   * @return A set with the supported types.
   */
  private Set<TypeMirror> getSupportedTypes(DeclaredType constraintAnnotationType) {

    Name key = getName( constraintAnnotationType );
    Set<TypeMirror> supportedTypes = supportedTypesByConstraint.get( key );

    // create a mapping for the given annotation type if required
    if ( supportedTypes == null ) {
      supportedTypes = determineSupportedTypes( constraintAnnotationType );
View Full Code Here

    DeclaredType annotation = annotationApiHelper.getDeclaredTypeByName( annotationType );

    if ( annotation == null ) {
      return;
    }
    Name key = getName( annotation );
    Set<TypeMirror> types = supportedTypesByConstraint.get( key );

    if ( types == null ) {
      supportedTypesByConstraint.put( key, new HashSet<TypeMirror>( supportedTypes ) );
    }
View Full Code Here

TOP

Related Classes of javax.lang.model.element.Name

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.