Search in sources :

Example 61 with MethodSpec

use of com.squareup.javapoet.MethodSpec in project BGABadgeView-Android by bingoogolapple.

the class BGABadgeProcessor method showDrawableBadge.

private void showDrawableBadge(TypeSpec.Builder typeBuilder) {
    MethodSpec methodSpec = MethodSpec.methodBuilder("showDrawableBadge").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC).addParameter(ClassName.get("android.graphics", "Bitmap"), "bitmap").addStatement("mBadgeViewHelper.showDrawable(bitmap)").build();
    typeBuilder.addMethod(methodSpec);
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec)

Example 62 with MethodSpec

use of com.squareup.javapoet.MethodSpec in project BGABadgeView-Android by bingoogolapple.

the class BGABadgeProcessor method callSuperOnTouchEvent.

private void callSuperOnTouchEvent(TypeSpec.Builder typeBuilder) {
    MethodSpec methodSpec = MethodSpec.methodBuilder("callSuperOnTouchEvent").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC).addParameter(ClassName.get("android.view", "MotionEvent"), "event").addStatement("return super.onTouchEvent(event)").returns(boolean.class).build();
    typeBuilder.addMethod(methodSpec);
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec)

Example 63 with MethodSpec

use of com.squareup.javapoet.MethodSpec in project BGABadgeView-Android by bingoogolapple.

the class BGABadgeProcessor method isDragging.

private void isDragging(TypeSpec.Builder typeBuilder) {
    MethodSpec methodSpec = MethodSpec.methodBuilder("isDragging").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC).addStatement("return mBadgeViewHelper.isDragging()").returns(boolean.class).build();
    typeBuilder.addMethod(methodSpec);
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec)

Example 64 with MethodSpec

use of com.squareup.javapoet.MethodSpec in project tiger by google.

the class NewInjectorGenerator method getGetModuleMethod.

private MethodSpec getGetModuleMethod(TypeElement scope, NewDependencyInfo dependencyInfo) {
    Preconditions.checkArgument(dependencyInfo.getProvisionMethodElement() != null, String.format("Expect one from module but get %s.", dependencyInfo));
    TypeElement module = dependencyInfo.getSourceClassElement();
    ClassName packagedInjectorClassName = getPackagedInjectorForNewDependencyInfo(scope, dependencyInfo);
    if (!modulesWithGetter.containsKey(packagedInjectorClassName)) {
        modulesWithGetter.put(packagedInjectorClassName, new HashMap<ClassName, MethodSpec>());
    }
    if (!modulesWithGetter.get(packagedInjectorClassName).containsKey(ClassName.get(module))) {
        generateGetModuleMethod(scope, dependencyInfo);
    }
    return modulesWithGetter.get(packagedInjectorClassName).get(ClassName.get(module));
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec) TypeElement(javax.lang.model.element.TypeElement) ClassName(com.squareup.javapoet.ClassName)

Example 65 with MethodSpec

use of com.squareup.javapoet.MethodSpec in project dagger by square.

the class InjectAdapterProcessor method getMethod.

private MethodSpec getMethod(ExecutableElement constructor, boolean disambiguateFields, boolean injectMembers, ClassName injectedClassName) {
    MethodSpec.Builder result = MethodSpec.methodBuilder("get").addJavadoc(AdapterJavadocs.GET_METHOD, injectedClassName).addAnnotation(Override.class).returns(injectedClassName).addModifiers(PUBLIC);
    result.addCode("$T result = new $T(", injectedClassName, injectedClassName);
    boolean first = true;
    for (VariableElement parameter : constructor.getParameters()) {
        if (!first)
            result.addCode(", ");
        else
            first = false;
        result.addCode("$N.get()", parameterName(disambiguateFields, parameter));
    }
    result.addCode(");\n");
    if (injectMembers) {
        result.addStatement("injectMembers(result)");
    }
    result.addStatement("return result");
    return result.build();
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec) VariableElement(javax.lang.model.element.VariableElement)

Aggregations

MethodSpec (com.squareup.javapoet.MethodSpec)155 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)43 TypeName (com.squareup.javapoet.TypeName)42 ArrayList (java.util.ArrayList)38 ClassName (com.squareup.javapoet.ClassName)34 TypeSpec (com.squareup.javapoet.TypeSpec)31 ParameterSpec (com.squareup.javapoet.ParameterSpec)24 CodeBlock (com.squareup.javapoet.CodeBlock)23 WildcardTypeName (com.squareup.javapoet.WildcardTypeName)20 Nonnull (javax.annotation.Nonnull)17 TypeMirror (javax.lang.model.type.TypeMirror)15 WireField (com.squareup.wire.WireField)14 Field (com.squareup.wire.schema.Field)14 TypeElement (javax.lang.model.element.TypeElement)14 ByteString (okio.ByteString)13 JvmLanguages.builtInAdapterString (com.squareup.wire.schema.internal.JvmLanguages.builtInAdapterString)12 List (java.util.List)11 VariableElement (javax.lang.model.element.VariableElement)11 Utf8String (org.fisco.bcos.web3j.abi.datatypes.Utf8String)11 FieldSpec (com.squareup.javapoet.FieldSpec)10