Package javax.lang.model.element

Examples of javax.lang.model.element.ExecutableElement


            processMethod(element);
        }
    }

    private void processMethod(Element element) {
        ExecutableElement methodElement = (ExecutableElement) element;
        String annotationType = null;
        for (AnnotationMirror annotationMirror : processingEnv.getElementUtils().getAllAnnotationMirrors(methodElement)) {
            Map<? extends ExecutableElement, ? extends AnnotationValue> annotationParameters =
                    processingEnv.getElementUtils().getElementValuesWithDefaults(annotationMirror);
            annotationType = annotationMirror.getAnnotationType().toString();
View Full Code Here


   *
   * @return A possibly non-empty set of constraint check errors, never null.
   */
  private Set<ConstraintCheckError> checkMessageAttribute(TypeElement element) {

    ExecutableElement messageMethod = getMethod( element, "message" );

    if ( messageMethod == null ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_MESSAGE_MEMBER" )
      );
    }

    if ( !typeUtils.isSameType(
        annotationApiHelper.getMirrorForType( String.class ), messageMethod.getReturnType()
    ) ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( messageMethod, null, "RETURN_TYPE_MUST_BE_STRING" )
      );
    }
View Full Code Here

   *
   * @return A possibly non-empty set of constraint check errors, never null.
   */
  private Set<ConstraintCheckError> checkGroupsAttribute(TypeElement element) {

    ExecutableElement groupsMethod = getMethod( element, "groups" );

    if ( groupsMethod == null ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_GROUPS_MEMBER" )
      );
    }

    DeclaredType type = getComponentTypeOfArrayReturnType( groupsMethod );

    if ( type == null ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( groupsMethod, null, "RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
      );
    }

    boolean typeHasNameClass = type.asElement().getSimpleName().contentEquals( "Class" );
    boolean typeHasExactlyOneTypeArgument = type.getTypeArguments().size() == 1;
    boolean typeArgumentIsUnboundWildcard = validateWildcardBounds( type.getTypeArguments().get( 0 ), null, null );

    if ( !( typeHasNameClass && typeHasExactlyOneTypeArgument && typeArgumentIsUnboundWildcard ) ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( groupsMethod, null, "RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
      );
    }

    if ( !isEmptyArray( groupsMethod.getDefaultValue() ) ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( groupsMethod, null, "DEFAULT_VALUE_MUST_BE_EMPTY_ARRAY" )
      );
    }

View Full Code Here

   *
   * @return A possibly non-empty set of constraint check errors, never null.
   */
  private Set<ConstraintCheckError> checkPayloadAttribute(TypeElement element) {

    ExecutableElement payloadMethod = getMethod( element, "payload" );

    if ( payloadMethod == null ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_PAYLOAD_MEMBER" )
      );
    }

    DeclaredType type = getComponentTypeOfArrayReturnType( payloadMethod );

    if ( type == null ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( payloadMethod, null, "PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
      );
    }

    boolean typeHasNameClass = type.asElement().getSimpleName().contentEquals( "Class" );
    boolean typeHasExactlyOneTypeArgument = type.getTypeArguments().size() == 1;
    boolean typeArgumentIsWildcardWithPayloadExtendsBound = validateWildcardBounds(
        type.getTypeArguments().get( 0 ),
        annotationApiHelper.getDeclaredTypeByName( BeanValidationTypes.PAYLOAD ),
        null
    );

    if ( !( typeHasNameClass && typeHasExactlyOneTypeArgument && typeArgumentIsWildcardWithPayloadExtendsBound ) ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( payloadMethod, null, "PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
      );
    }

    if ( !isEmptyArray( payloadMethod.getDefaultValue() ) ) {
      return CollectionHelper.asSet(
          new ConstraintCheckError( payloadMethod, null, "PAYLOAD_DEFAULT_VALUE_MUST_BE_EMPTY_ARRAY" )
      );
    }

View Full Code Here

            AnnotationState annotation = router.annotations.get(method.getMethod());
            if (annotation != null) {
              String path = (String)annotation.get("value");
              Integer priority = (Integer)annotation.get("priority");
              HashMap<String, ParamDescriptor> parameters = null;
              ExecutableElement exe = metaModel.processingContext.get(method.getMethod());
              for (VariableElement ve : exe.getParameters()) {
                Param param = ve.getAnnotation(Param.class);
                if (param != null) {
                  if (parameters == null) {
                    parameters = new HashMap<String, ParamDescriptor>();
                  }
View Full Code Here

            if (!modifiers.contains(Modifier.PUBLIC)) {
              throw PROVIDER_FACTORY_NOT_PUBLIC.failure(env.get(key.getElement()), implementationElt.getQualifiedName());
            }

            // Find zero arg constructor
            ExecutableElement emptyCtor = null;
            for (ExecutableElement ctorElt : ElementFilter.constructorsIn(env.getAllMembers(implementationElt))) {
              if (ctorElt.getParameters().isEmpty()) {
                emptyCtor = ctorElt;
                break;
              }
            }

            // Validate constructor
            if (emptyCtor == null) {
              throw PROVIDER_FACTORY_NO_ZERO_ARG_CTOR.failure(env.get(key.getElement()), implementationElt.getQualifiedName());
            }
            if (!emptyCtor.getModifiers().contains(Modifier.PUBLIC)) {
              throw PROVIDER_FACTORY_NO_PUBLIC_CTOR.failure(env.get(key.getElement()), implementationElt.getQualifiedName());
            }
          }
          else if (env.isAssignable(implementationTM, rawProviderTM)) {
            TypeVariable T = (TypeVariable)providerTM.getTypeArguments().get(0);
View Full Code Here

    //
    TypeElement annotationTypeElement = (TypeElement)annotation.getAnnotationType().asElement();
    Map<? extends ExecutableElement, ? extends AnnotationValue> values = annotation.getElementValues();
    for (Element member : annotationTypeElement.getEnclosedElements()) {
      if (member instanceof ExecutableElement) {
        ExecutableElement xMember = (ExecutableElement)member;
        AnnotationValue value = values.get(xMember);
        String key = xMember.getSimpleName().toString();
        HashMap<String, Serializable> target;
        if (value == null) {
          if (state.undeclared == null) {
            state.undeclared = new HashMap<String, Serializable>();
          }
          target = state.undeclared;
          value = xMember.getDefaultValue();
        } else {
          target = state;
        }
        if (value != null) {
          Serializable serialized = unwrap(value, xMember.getReturnType());
          target.put(key, serialized);
        }
      }
    }
View Full Code Here

      case PACKAGE: {
        PackageElement packageElt = (PackageElement)elt;
        return Package.create(packageElt);
      }
      case METHOD: {
        ExecutableElement packageElt = (ExecutableElement)elt;
        return Method.create(packageElt);
      }
      default:
        throw new UnsupportedOperationException("Element " + elt + " with kind " + kind + " not supported");
    }
View Full Code Here

  void addMethod(ModuleMetaModel context, AnnotationKey annotationKey, AnnotationState annotationState) {

    //
    String id = (String)annotationState.get("id");
    ElementHandle.Method methodHandle = (ElementHandle.Method)annotationKey.getElement();
    ExecutableElement methodElt = context.processingContext.get(methodHandle);
    ProcessingContext.log.log(Level.FINE, "Adding method " + methodElt + " to controller class " + handle);

    //
    for (Phase phase : Phase.values()) {
      if (phase.annotation.getName().equals(annotationKey.getType().toString())) {

        // First remove the previous method
        Key<HandlerMetaModel> key = Key.of(methodHandle, HandlerMetaModel.class);
        if (getChild(key) == null) {
          // Parameters
          ArrayList<ParameterMetaModel> parameters = new ArrayList<ParameterMetaModel>();
          List<? extends TypeMirror> parameterTypeMirrors = ((ExecutableType)methodElt.asType()).getParameterTypes();
          List<? extends VariableElement> parameterVariableElements = methodElt.getParameters();
          for (int i = 0;i < parameterTypeMirrors.size();i++) {
            VariableElement parameterVariableElt = parameterVariableElements.get(i);
            TypeMirror parameterTypeMirror = parameterTypeMirrors.get(i);
            ParameterMetaModel parameterMetaModel = foo(context, parameterVariableElt, parameterTypeMirror);
            parameters.add(parameterMetaModel);
          }

          //
          HandlerMetaModel method = new HandlerMetaModel(
            methodHandle,
            id,
            phase,
            methodElt.getSimpleName().toString(),
            parameters);
          addChild(key, method);
          modified = true;
          ProcessingContext.log.log(Level.FINE, "Added method " + methodHandle + " to controller class " + handle);
        }
View Full Code Here

          if (count.getAndIncrement() == 0) {
            ElementHandle.Field index = ElementHandle.Field.create("plugin.template.completion.A", "index");
            VariableElement indexElt = index.get(processingEnv);
            AnnotationMirror pathAnn = indexElt.getAnnotationMirrors().get(0);
            TypeElement annotationTypeElement = (TypeElement)pathAnn.getAnnotationType().asElement();
            ExecutableElement value = (ExecutableElement)annotationTypeElement.getEnclosedElements().get(0);
            for (Completion completion : getCompletions(indexElt, pathAnn, value, test[0])) {
              completions.add(completion.getValue());
            }
          }
        }
View Full Code Here

TOP

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

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.