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);
}
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);
}
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);
}
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));
}
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();
}
Aggregations