Java Code Examples for javax.lang.model.element.ExecutableElement#getAnnotation()

The following examples show how to use javax.lang.model.element.ExecutableElement#getAnnotation() . 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: RetroWeiboProcessor.java    From SimpleWeibo with Apache License 2.0 6 votes vote down vote up
public String buildPath(ExecutableElement method) {
  // TODO duplicated routine
  retroweibo.RetroWeibo.GET get = method.getAnnotation(retroweibo.RetroWeibo.GET.class);
  retroweibo.RetroWeibo.POST post = method.getAnnotation(retroweibo.RetroWeibo.POST.class);
  retroweibo.RetroWeibo.DELETE delete = method.getAnnotation(retroweibo.RetroWeibo.DELETE.class);
  String fullPath = null;
  if (get != null) fullPath = get.value();
  if (post != null) fullPath = post.value();
  if (delete != null) fullPath = delete.value();

  List<? extends VariableElement> parameters = method.getParameters();
  for (VariableElement parameter : parameters) {
    retroweibo.RetroWeibo.Path path = parameter
        .getAnnotation(retroweibo.RetroWeibo.Path.class);
    if ((path != null) && (!path.value().equals("null"))) {
      fullPath = fullPath.replace("{" + path.value() + "}", "\" + " +
          parameter.getSimpleName().toString() + " + \"");
    } else {
      fullPath = fullPath.replace("{" + parameter.getSimpleName().toString() + "}", "\" + " +
          parameter.getSimpleName().toString() + " + \"");
    }
  }

  return "\"" + fullPath.replaceAll("\\?.+", "") + "\"";
}
 
Example 2
Source File: RetroFacebookProcessor.java    From RetroFacebook with Apache License 2.0 6 votes vote down vote up
public String buildBody(ExecutableElement method) {
  String body = "";

  // TODO duplicated routine
  retrofacebook.RetroFacebook.POST post = method.getAnnotation(retrofacebook.RetroFacebook.POST.class);
  if (post == null) return body;

  // TODO duplicated code
  List<? extends VariableElement> parameters = method.getParameters();
  for (VariableElement parameter : parameters) {
    if (parameter.getAnnotation(retrofacebook.RetroFacebook.Body.class) != null) {
      body = parameter.getSimpleName().toString();
    }
  }
  return body;
}
 
Example 3
Source File: WebServiceVisitor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean hasWebMethods(TypeElement element) {
    if (element.getQualifiedName().toString().equals(Object.class.getName()))
        return false;
    WebMethod webMethod;
    for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {
        webMethod = method.getAnnotation(WebMethod.class);
        if (webMethod != null) {
            if (webMethod.exclude()) {
                if (webMethod.operationName().length() > 0)
                    builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE(
                            "operationName", element.getQualifiedName(), method.toString()), method);
                if (webMethod.action().length() > 0)
                    builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE(
                            "action", element.getQualifiedName(), method.toString()), method);
            } else {
                return true;
            }
        }
    }
    return false;//hasWebMethods(d.getSuperclass().getDeclaration());
}
 
Example 4
Source File: WebServiceVisitor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected boolean hasWebMethods(TypeElement element) {
    if (element.getQualifiedName().toString().equals(Object.class.getName()))
        return false;
    WebMethod webMethod;
    for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {
        webMethod = method.getAnnotation(WebMethod.class);
        if (webMethod != null) {
            if (webMethod.exclude()) {
                if (webMethod.operationName().length() > 0)
                    builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE(
                            "operationName", element.getQualifiedName(), method.toString()), method);
                if (webMethod.action().length() > 0)
                    builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE(
                            "action", element.getQualifiedName(), method.toString()), method);
            } else {
                return true;
            }
        }
    }
    return false;//hasWebMethods(d.getSuperclass().getDeclaration());
}
 
Example 5
Source File: WebServiceVisitor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitExecutable(ExecutableElement method, Object o) {
    // Methods must be public
    if (!method.getModifiers().contains(Modifier.PUBLIC))
        return null;
    if (processedMethod(method))
        return null;
    WebMethod webMethod = method.getAnnotation(WebMethod.class);
    if (webMethod != null && webMethod.exclude())
        return null;
    SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
    if (soapBinding == null && !method.getEnclosingElement().equals(typeElement)) {
        if (method.getEnclosingElement().getKind().equals(ElementKind.CLASS)) {
            soapBinding = method.getEnclosingElement().getAnnotation(SOAPBinding.class);
            if (soapBinding != null)
                builder.log("using " + method.getEnclosingElement() + "'s SOAPBinding.");
            else {
                soapBinding = new MySoapBinding();
            }
        }
    }
    boolean newBinding = false;
    if (soapBinding != null) {
        newBinding = pushSoapBinding(soapBinding, method, typeElement);
    }
    try {
        if (shouldProcessMethod(method, webMethod)) {
            processMethod(method, webMethod);
        }
    } finally {
        if (newBinding) {
            popSoapBinding();
        }
    }
    return null;
}
 
Example 6
Source File: ClassStructure.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Hint(displayName = "#DN_org.netbeans.modules.java.hints.ClassStructure.finalMethodInFinalClass", description = "#DESC_org.netbeans.modules.java.hints.ClassStructure.finalMethodInFinalClass", category = "class_structure", enabled = false, suppressWarnings = {"FinalMethodInFinalClass"}) //NOI18N
@TriggerTreeKind(Kind.METHOD)
public static ErrorDescription finalMethodInFinalClass(HintContext context) {
    final MethodTree mth = (MethodTree) context.getPath().getLeaf();
    final Tree parent = context.getPath().getParentPath().getLeaf();
    if (TreeUtilities.CLASS_TREE_KINDS.contains(parent.getKind()) && mth.getModifiers().getFlags().contains(Modifier.FINAL) && ((ClassTree) parent).getModifiers().getFlags().contains(Modifier.FINAL)) {
        // see defect #236974; although redundant, if the method is annotated with @SafeVarargs, we must permit final modifier.
        ExecutableElement ee = (ExecutableElement)context.getInfo().getTrees().getElement(context.getPath());
        if (ee == null || ee.getAnnotation(SafeVarargs.class) == null) {
            return ErrorDescriptionFactory.forName(context, mth, NbBundle.getMessage(ClassStructure.class, "MSG_FinalMethodInFinalClass", mth.getName()), //NOI18N
                    FixFactory.removeModifiersFix(context.getInfo(), TreePath.getPath(context.getPath(), mth.getModifiers()), EnumSet.of(Modifier.FINAL), NbBundle.getMessage(ClassStructure.class, "FIX_RemoveFinalFromMethod", mth.getName()))); //NOI18N
        }
    }
    return null;
}
 
Example 7
Source File: Key.java    From dagger2-sample with Apache License 2.0 5 votes vote down vote up
Key forProvidesMethod(ExecutableType executableType, ExecutableElement e) {
  checkNotNull(e);
  checkArgument(e.getKind().equals(METHOD));
  Provides providesAnnotation = e.getAnnotation(Provides.class);
  checkArgument(providesAnnotation != null);
  TypeMirror returnType = normalize(types, executableType.getReturnType());
  switch (providesAnnotation.type()) {
    case UNIQUE:
      return new AutoValue_Key(
          wrapOptionalInEquivalence(AnnotationMirrors.equivalence(), getQualifier(e)),
          MoreTypes.equivalence().wrap(returnType));
    case SET:
      TypeMirror setType = types.getDeclaredType(getSetElement(), returnType);
      return new AutoValue_Key(
          wrapOptionalInEquivalence(AnnotationMirrors.equivalence(), getQualifier(e)),
          MoreTypes.equivalence().wrap(setType));
    case MAP:
      AnnotationMirror mapKeyAnnotation = Iterables.getOnlyElement(getMapKeys(e));
      MapKey mapKey =
          mapKeyAnnotation.getAnnotationType().asElement().getAnnotation(MapKey.class);
      TypeElement keyTypeElement =
          mapKey.unwrapValue() ? Util.getKeyTypeElement(mapKeyAnnotation, elements)
              : (TypeElement) mapKeyAnnotation.getAnnotationType().asElement();
      TypeMirror valueType = types.getDeclaredType(getProviderElement(), returnType);
      TypeMirror mapType =
          types.getDeclaredType(getMapElement(), keyTypeElement.asType(), valueType);
      return new AutoValue_Key(
          wrapOptionalInEquivalence(AnnotationMirrors.equivalence(), getQualifier(e)),
          MoreTypes.equivalence().wrap(mapType));
    case SET_VALUES:
      // TODO(gak): do we want to allow people to use "covariant return" here?
      checkArgument(returnType.getKind().equals(DECLARED));
      checkArgument(((DeclaredType) returnType).asElement().equals(getSetElement()));
      return new AutoValue_Key(
          wrapOptionalInEquivalence(AnnotationMirrors.equivalence(), getQualifier(e)),
          MoreTypes.equivalence().wrap(returnType));
    default:
      throw new AssertionError();
  }
}
 
Example 8
Source File: AutoReducerInit.java    From reductor with Apache License 2.0 5 votes vote down vote up
public static AutoReducerInit parse(Env env, ExecutableElement executableElement, TypeMirror stateType) throws ValidationException {
    if (executableElement.getAnnotation(AutoReducer.Action.class) != null) {
        throw new ValidationException(executableElement, "Method %s should be may be annotated" +
                " with either @AutoReducer.InitialState or @AutoReducer.Action but not both", executableElement);
    }

    ValidationUtils.validateReturnsState(env, stateType, executableElement);
    ValidationUtils.validateIsNotPrivate(executableElement);

    int paramsCount = executableElement.getParameters().size();
    if (paramsCount != 0) {
        throw new ValidationException(executableElement, "Method %s should not have any parameters", executableElement);
    }
    return new AutoReducerInit(executableElement);
}
 
Example 9
Source File: AnnotatedMethod.java    From SensorAnnotations with Apache License 2.0 5 votes vote down vote up
AnnotatedMethod(@NonNull ExecutableElement methodElement,
    @NonNull Class<? extends Annotation> annotationClass) throws IllegalArgumentException {
    Annotation annotation = methodElement.getAnnotation(annotationClass);
    mAnnotatedMethodElement = methodElement;
    mDelay = getDelayFromAnnotation(annotation);
    mSensorType = getSensorTypeFromAnnotation(annotation);

    if (mSensorType == INVALID_SENSOR) {
        throw new IllegalArgumentException(String.format(
            "No sensor type specified in @%s for method %s."
                + " Set a sensor type such as Sensor.TYPE_ACCELEROMETER.",
            annotationClass.getSimpleName(), methodElement.getSimpleName().toString()));
    }
}
 
Example 10
Source File: MethodExtractorUtils.java    From litho with Apache License 2.0 5 votes vote down vote up
private static boolean canCreateDiffModels(
    ExecutableElement method,
    List<Class<? extends Annotation>> delegateMethodAnnotationsThatSkipDiffModels) {

  for (Class<? extends Annotation> delegate : delegateMethodAnnotationsThatSkipDiffModels) {
    if (method.getAnnotation(delegate) != null) {
      return false;
    }
  }

  return true;
}
 
Example 11
Source File: BuilderProcessor.java    From pocketknife with Apache License 2.0 5 votes vote down vote up
private IntentMethodBinding getIntentMethodBinding(ExecutableElement element) throws InvalidTypeException {
    IntentBuilder intentBuilder = element.getAnnotation(IntentBuilder.class);
    String intentBuilderName = IntentBuilder.class.getName();
    String action = null;
    if (!isDefaultAnnotationElement(element, intentBuilderName, "action")) {
        action = intentBuilder.action();
    }
    Element dataParam = getIntentData(element);
    String dataParamName = null;
    if (dataParam != null) {
        dataParamName = dataParam.getSimpleName().toString();
    }
    boolean dataParamIsString = dataParam != null && types.isAssignable(dataParam.asType(), typeUtil.stringType);
    Integer flags = null;
    if (!isDefaultAnnotationElement(element, intentBuilderName, "flags")) {
        flags = intentBuilder.flags();
    }
    String type = null;
    if (!isDefaultAnnotationElement(element, intentBuilderName, "type")) {
        type = intentBuilder.type();
    }

    IntentMethodBinding binding = new IntentMethodBinding(element.getSimpleName().toString(), getIntentBuilderClsValue(element), action,
            dataParamName, flags, intentBuilder.categories(), type, dataParamIsString);
    for (Element parameter : element.getParameters()) {
        binding.addField(getIntentFieldBinding(parameter));
    }
    return binding;
}
 
Example 12
Source File: OperatorProcessor.java    From java with Apache License 2.0 4 votes vote down vote up
private void collectOpMethods(
    Multimap<String, MethodSpec> groupedMethods, TypeElement opClass, TypeElement annotation) {
  boolean opClassDeprecated = opClass.getAnnotation(Deprecated.class) != null;
  AnnotationMirror operatorAnnot = getAnnotationMirror(opClass, annotation.getQualifiedName());
  if (operatorAnnot == null) {
    throw new IllegalArgumentException(
        "Annotation "
            + annotation.getSimpleName()
            + " not present on element "
            + opClass.getSimpleName());
  }
  String opGroup = getAnnotationElementValueAsString("group", operatorAnnot);
  String opName = getAnnotationElementValueAsString("name", operatorAnnot);
  if (Strings.isNullOrEmpty(opName)) {
    opName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, ClassName.get(opClass).simpleName());
  }
  // Build an endpoint for each method annotated with @Endpoint, which takes in parameter a scope
  // and, optionally, a list of arguments
  for (ExecutableElement opMethod : ElementFilter.methodsIn(opClass.getEnclosedElements())) {
    AnnotationMirror endpointAnnot =
        getAnnotationMirror(opMethod, elements.getName(T_ENDPOINT.toString()));
    if (endpointAnnot != null) {
      if (!opMethod.getModifiers().containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))) {
        throw new IllegalArgumentException(
            "Endpoint " + opMethod + " of class " + opClass + " must be static and public");
      }
      if (opMethod.getParameters().isEmpty() ||
          !((TypeElement)types.asElement(opMethod.getParameters().get(0).asType())).getQualifiedName()
              .equals(elements.getName(T_SCOPE.toString()))) {
        throw new IllegalArgumentException(
            "Endpoint " + opMethod + " of class " + opClass + " must take an instance of " + T_SCOPE
                + " as its first parameter");
      }
      String endpointGroup = getAnnotationElementValueAsString("group", endpointAnnot);
      if (endpointGroup.isEmpty()) {
        endpointGroup = opGroup;
      }
      String endpointName = getAnnotationElementValueAsString("name", endpointAnnot);
      if (endpointName.isEmpty()) {
        endpointName = opName;
      }
      boolean describeByClass =
          getAnnotationElementValueAsBoolean("describeByClass", endpointAnnot, false);
      boolean deprecated = opMethod.getAnnotation(Deprecated.class) != null || opClassDeprecated;
      MethodSpec method = buildOpMethod(endpointName, opClass, opMethod, describeByClass, deprecated);
      groupedMethods.put(endpointGroup, method);
    }
  }
}
 
Example 13
Source File: WebServiceVisitor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
    WebMethod webMethod = method.getAnnotation(WebMethod.class);
    //SEI cannot have methods with @WebMethod(exclude=true)
    if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
        builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
    // With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
    if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
        return true;

    if ((webMethod != null) && webMethod.exclude()) {
        return true;
    }
    /*
    This check is not needed as Impl class is already checked that it is not abstract.
    if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) {  // use Kind.equals instead of instanceOf
        builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
        return false;
    }
    */
    TypeMirror returnType = method.getReturnType();
    if (!isLegalType(returnType)) {
        builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
                method.getSimpleName(),
                returnType), method);
    }
    boolean isOneWay = method.getAnnotation(Oneway.class) != null;
    if (isOneWay && !isValidOneWayMethod(method, typeElement))
        return false;

    SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
    if (soapBinding != null) {
        if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
        }
    }

    int paramIndex = 0;
    for (VariableElement parameter : method.getParameters()) {
        if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
            return false;
    }

    if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
        VariableElement outParam = getOutParameter(method);
        int inParams = getModeParameterCount(method, WebParam.Mode.IN);
        int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
        if (inParams != 1) {
            builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
        }
        if (returnType.accept(NO_TYPE_VISITOR, null)) {
            if (outParam == null && !isOneWay) {
                builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
            }
            if (outParams != 1) {
                if (!isOneWay && outParams != 0)
                    builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
            }
        } else {
            if (outParams > 0) {
                builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
            }
        }
    }
    return true;
}
 
Example 14
Source File: RetroFacebookProcessor.java    From RetroFacebook with Apache License 2.0 4 votes vote down vote up
public boolean buildIsGet(ExecutableElement method) {
    // TODO duplicated routine
    return method.getAnnotation(retrofacebook.RetroFacebook.GET.class) != null;
}
 
Example 15
Source File: InlineAnnotationReaderImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMethodAnnotation(Class<? extends Annotation> a, ExecutableElement method) {
    return method.getAnnotation(a)!=null;
}
 
Example 16
Source File: RepositoryParser.java    From YoDao with Apache License 2.0 4 votes vote down vote up
private static List<DaoMethod> parserMethods(Element element) {
	boolean isInterface = element.getKind().isInterface();
	List<DaoMethod> methods = new ArrayList<DaoMethod>();
	List<? extends Element> elems = element.getEnclosedElements();
	for (Element e : elems) {
		if (e instanceof ExecutableElement
				&& e.getKind() == ElementKind.METHOD) {
			ExecutableElement executableElement = (ExecutableElement) e;
			TypeElement enclosingElement = (TypeElement) e
					.getEnclosingElement();
			if (isInterface || isAbstract(executableElement)) {
				DaoMethod method = new DaoMethod();
				String methodName = executableElement.getSimpleName()
						.toString();
				method.setMethodName(methodName);
				String returnType = executableElement.getReturnType()
						.toString();
				method.setReturnType(returnType);
				com.yoda.yodao.annotation.Query query = executableElement
						.getAnnotation(com.yoda.yodao.annotation.Query.class);
				if (query != null) {
					method.setSql(query.value());
				}

				List<? extends VariableElement> parameters = executableElement
						.getParameters();
				int count = parameters.size();
				if (parameters != null && count > 0) {
					DaoParam[] params = new DaoParam[count];
					for (int i = 0; i < count; i++) {
						VariableElement param = parameters.get(i);
						String paramType = param.asType().toString();
						String paramName = param.getSimpleName().toString();
						params[i] = new DaoParam(paramName, paramType);
					}
					method.setMethodParams(params);
				}

				method.setElement(e);
				methods.add(method);
			}
		}
	}

	return methods;
}
 
Example 17
Source File: InlineAnnotationReaderImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public boolean hasMethodAnnotation(Class<? extends Annotation> a, ExecutableElement method) {
    return method.getAnnotation(a)!=null;
}
 
Example 18
Source File: RetroFacebookProcessor.java    From RetroFacebook with Apache License 2.0 4 votes vote down vote up
public boolean buildIsPost(ExecutableElement method) {
    // TODO duplicated routine
    return method.getAnnotation(retrofacebook.RetroFacebook.POST.class) != null;
}
 
Example 19
Source File: TypeDefUtils.java    From sundrio with Apache License 2.0 4 votes vote down vote up
public static boolean isTerminal(ExecutableElement executableElement) {
    return executableElement.getAnnotation(Terminal.class) != null;
}
 
Example 20
Source File: ControllerProcessor.java    From AndServer with Apache License 2.0 4 votes vote down vote up
private void createHandlerAdapter(String registerPackageName,
    Map<TypeElement, List<ExecutableElement>> controllers) {
    Map<String, List<String>> adapterMap = new HashMap<>();
    for (Map.Entry<TypeElement, List<ExecutableElement>> entry : controllers.entrySet()) {
        TypeElement type = entry.getKey();
        List<ExecutableElement> executes = entry.getValue();
        mLog.i(String.format("------ Processing %s ------", type.getSimpleName()));

        String typeName = type.getQualifiedName().toString();
        Mapping typeMapping = getTypeMapping(type);
        validateMapping(typeMapping, typeName);

        TypeName controllerType = TypeName.get(type.asType());
        FieldSpec hostField = FieldSpec.builder(controllerType, "mHost", Modifier.PRIVATE).build();
        FieldSpec mappingField = FieldSpec.builder(mMappingList, "mMappingMap", Modifier.PRIVATE).build();

        CodeBlock.Builder rootCode = CodeBlock.builder()
            .addStatement("this.mHost = new $T()", type)
            .addStatement("this.mMappingMap = new $T<>()", LinkedHashMap.class);
        for (ExecutableElement execute : executes) {
            Mapping mapping = getExecuteMapping(execute);
            validateExecuteMapping(mapping, typeName + "#" + execute.getSimpleName().toString() + "()");

            mapping = new Merge(typeMapping, mapping);
            rootCode.beginControlFlow("\n").addStatement("$T mapping = new $T()", mMapping, mMapping);
            addMapping(rootCode, mapping);

            Addition addition = execute.getAnnotation(Addition.class);
            rootCode.add("\n").addStatement("$T addition = new $T()", mAddition, mAddition);
            addAddition(rootCode, addition);

            String handlerName = createHandler(type, execute, mapping.path(), mapping.isRest());
            rootCode.addStatement("$L handler = new $L(mHost, mapping, addition, $L)", handlerName, handlerName,
                mapping.isRest()).addStatement("mMappingMap.put(mapping, handler)").endControlFlow();
        }
        MethodSpec rootMethod = MethodSpec.constructorBuilder()
            .addModifiers(Modifier.PUBLIC)
            .addCode(rootCode.build())
            .build();

        MethodSpec mappingMethod = MethodSpec.methodBuilder("getMappingMap")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PROTECTED)
            .returns(mMappingList)
            .addStatement("return mMappingMap")
            .build();

        MethodSpec hostMethod = MethodSpec.methodBuilder("getHost")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PROTECTED)
            .returns(controllerType)
            .addStatement("return mHost")
            .build();

        String adapterPackageName = getPackageName(type).getQualifiedName().toString();
        String className = String.format("%sAdapter", type.getSimpleName());
        TypeSpec adapterClass = TypeSpec.classBuilder(className)
            .addJavadoc(Constants.DOC_EDIT_WARN)
            .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
            .superclass(mMappingAdapter)
            .addField(hostField)
            .addField(mappingField)
            .addMethod(rootMethod)
            .addMethod(mappingMethod)
            .addMethod(hostMethod)
            .build();

        JavaFile javaFile = JavaFile.builder(adapterPackageName, adapterClass).build();
        try {
            javaFile.writeTo(mFiler);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        String group = getGroup(type);
        List<String> adapterList = adapterMap.get(group);
        if (CollectionUtils.isEmpty(adapterList)) {
            adapterList = new ArrayList<>();
            adapterMap.put(group, adapterList);
        }
        adapterList.add(adapterPackageName + "." + className);
    }

    if (!adapterMap.isEmpty()) {
        createRegister(registerPackageName, adapterMap);
    }
}