Package javax.lang.model.util

Examples of javax.lang.model.util.Elements


        return null;
    }

    private String getCategory(final TypeElement e)
    {
        Elements elementUtils = processingEnv.getElementUtils();
        TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_OBJECT_CANONICAL_NAME);
        String category = null;
        List<? extends AnnotationMirror> annotationMirrors = e.getAnnotationMirrors();
        if(annotationMirrors != null)
        {
            for (AnnotationMirror a : annotationMirrors)
View Full Code Here


    public void processAttributes(final RoundEnvironment roundEnv,
                                  String elementName)
    {

        Elements elementUtils = processingEnv.getElementUtils();
        TypeElement annotationElement = elementUtils.getTypeElement(elementName);

        for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement))
        {
            checkAnnotationIsOnMethodInInterface(annotationElement, e);
View Full Code Here

    public void processStatistics(final RoundEnvironment roundEnv,
                                  String elementName)
    {

        Elements elementUtils = processingEnv.getElementUtils();
        TypeElement annotationElement = elementUtils.getTypeElement(elementName);

        for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement))
        {
            checkAnnotationIsOnMethodInInterface(annotationElement, e);
View Full Code Here

    private void checkMethodReturnTypeIsNumber(final TypeElement annotationElement,
                                               final ExecutableElement methodElement)
    {
        Types typeUtils = processingEnv.getTypeUtils();
        Elements elementUtils = processingEnv.getElementUtils();

        TypeMirror numberType = elementUtils.getTypeElement("java.lang.Number").asType();
        if(!typeUtils.isAssignable(methodElement.getReturnType(),numberType))
        {
            processingEnv.getMessager()
                    .printMessage(Diagnostic.Kind.ERROR,
                                  "@"
View Full Code Here

    }

    private boolean isValidType(final TypeMirror type)
    {
        Types typeUtils = processingEnv.getTypeUtils();
        Elements elementUtils = processingEnv.getElementUtils();
        Element typeElement = typeUtils.asElement(type);

        if (VALID_PRIMITIVE_TYPES.contains(type.getKind()))
        {
            return true;
        }
        for(TypeKind primitive : VALID_PRIMITIVE_TYPES)
        {
            if(typeUtils.isSameType(type, typeUtils.boxedClass(typeUtils.getPrimitiveType(primitive)).asType()))
            {
                return true;
            }
        }
        if(typeElement.getKind()==ElementKind.ENUM)
        {
            return true;
        }

        String className = "org.apache.qpid.server.model.ConfiguredObject";
        TypeMirror configuredObjectType = getErasure(className);

        if(typeUtils.isAssignable(typeUtils.erasure(type), configuredObjectType))
        {
            return true;
        }

        if(typeUtils.isSameType(type, elementUtils.getTypeElement("java.lang.String").asType()))
        {
            return true;
        }


        if(typeUtils.isSameType(type,elementUtils.getTypeElement("java.util.UUID").asType()))
        {
            return true;
        }

        TypeMirror erasedType = typeUtils.erasure(type);
View Full Code Here

    }

    private TypeMirror getErasure(final String className)
    {
        final Types typeUtils = processingEnv.getTypeUtils();
        final Elements elementUtils = processingEnv.getElementUtils();
        return typeUtils.erasure(elementUtils.getTypeElement(className).asType());
    }
View Full Code Here

    }

    @Override
    public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv)
    {
        Elements elementUtils = processingEnv.getElementUtils();
        Types typeUtils = processingEnv.getTypeUtils();

        TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_ATTRIBUTE_FIELD_CLASS_NAME);
        for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement))
        {
            for(AnnotationMirror am : e.getAnnotationMirrors())
            {
                if(typeUtils.isSameType(am.getAnnotationType(), annotationElement.asType()))
View Full Code Here

    private void collectData(final RoundEnvironment roundEnv) throws Exception {

        final Messager messager = processingEnv.getMessager();
        final Types typeUtils = processingEnv.getTypeUtils();
        final Elements elementUtils = processingEnv.getElementUtils();

        for (Element e : roundEnv.getElementsAnnotatedWith(Store.class)) {
            TypeElement storeElement = (TypeElement) e;
            PackageElement packageElement = (PackageElement) storeElement.getEnclosingElement();

            final String packageName = packageElement.getQualifiedName().toString();
            final String storeDelegate = storeElement.getSimpleName().toString();
            final boolean changeSupport = typeUtils.isAssignable(storeElement.asType(),
                    elementUtils.getTypeElement(ChangeSupport.class.getName()).asType());
            final String storeClassName = GenerationUtil.storeImplementation(storeDelegate);
            messager.printMessage(NOTE,
                    String.format("Discovered annotated store [%s]", storeElement.getQualifiedName()));

            List<ExecutableElement> processMethods = new ArrayList<>();
View Full Code Here

    static List<ExecutableElement> getAnnotatedMethods(final TypeElement originalClassElement,
            final ProcessingEnvironment processingEnvironment, final String annotationName,
            final TypeMirror requiredReturnType, final String[] requiredParameterTypes) {

        final Types typeUtils = processingEnvironment.getTypeUtils();
        final Elements elementUtils = processingEnvironment.getElementUtils();

        TypeElement classElement = originalClassElement;
        while (true) {
            final List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements());
View Full Code Here

      } else {
        return op;
      }
    }

    Elements elements = processingEnv.getElementUtils();
    TypeMirror type = arg.getElement().asType();
    Types types = processingEnv.getTypeUtils();
    String[] arrayListTypes = new String[] {
        String.class.getName(), Integer.class.getName(), CharSequence.class.getName()
    };
    String[] arrayListOps =
        new String[] { "StringArrayList", "IntegerArrayList", "CharSequenceArrayList" };
    for (int i = 0; i < arrayListTypes.length; i++) {
      TypeMirror tm = getArrayListType(arrayListTypes[i]);
      if (types.isAssignable(type, tm)) {
        return arrayListOps[i];
      }
    }

    if (types.isAssignable(type,
        getWildcardType(ArrayList.class.getName(), "android.os.Parcelable"))) {
      return "ParcelableArrayList";
    }
    TypeMirror sparseParcelableArray =
        getWildcardType("android.util.SparseArray", "android.os.Parcelable");

    if (types.isAssignable(type, sparseParcelableArray)) {
      return "SparseParcelableArray";
    }

    if (types.isAssignable(type, elements.getTypeElement(Serializable.class.getName()).asType())) {
      return "Serializable";
    }

    if (types.isAssignable(type, elements.getTypeElement("android.os.Parcelable").asType())) {
      return "Parcelable";
    }

    return null;
  }
View Full Code Here

TOP

Related Classes of javax.lang.model.util.Elements

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.