Search in sources :

Example 6 with MethodDeclarationParameters

use of com.yahoo.aptutils.writer.parameters.MethodDeclarationParameters in project squidb by yahoo.

the class BasicPropertyGenerator method emitSetter.

@Override
public final void emitSetter(JavaFileWriter writer) throws IOException {
    if (isDeprecated) {
        return;
    }
    MethodDeclarationParameters params = setterMethodParams();
    modelSpec.getPluginBundle().beforeEmitSetter(writer, this, params);
    writer.beginMethodDefinition(params);
    writeSetterBody(writer, params);
    writer.finishMethodDefinition();
    modelSpec.getPluginBundle().afterEmitSetter(writer, this, params);
}
Also used : MethodDeclarationParameters(com.yahoo.aptutils.writer.parameters.MethodDeclarationParameters)

Example 7 with MethodDeclarationParameters

use of com.yahoo.aptutils.writer.parameters.MethodDeclarationParameters in project squidb by yahoo.

the class ModelMethodPlugin method emitModelMethod.

private void emitModelMethod(JavaFileWriter writer, ExecutableElement e, Modifier... modifiers) throws IOException {
    MethodDeclarationParameters params = utils.methodDeclarationParamsFromExecutableElement(e, modifiers);
    ModelMethod methodAnnotation = e.getAnnotation(ModelMethod.class);
    List<Object> arguments = new ArrayList<>();
    if (methodAnnotation != null) {
        String name = methodAnnotation.name();
        if (!AptUtils.isEmpty(name)) {
            params.setMethodName(name);
        }
        params.getArgumentTypes().remove(0);
        params.getArgumentNames().remove(0);
        arguments.add(0, "this");
    }
    arguments.addAll(params.getArgumentNames());
    Expression methodCall = Expressions.staticMethod(modelSpec.getModelSpecName(), e.getSimpleName().toString(), arguments);
    if (!CoreTypes.VOID.equals(params.getReturnType())) {
        methodCall = methodCall.returnExpr();
    }
    JavadocPlugin.writeJavadocFromElement(pluginEnv, writer, e);
    writer.beginMethodDefinition(params).writeStatement(methodCall).finishMethodDefinition();
}
Also used : ModelMethod(com.yahoo.squidb.annotations.ModelMethod) Expression(com.yahoo.aptutils.writer.expressions.Expression) MethodDeclarationParameters(com.yahoo.aptutils.writer.parameters.MethodDeclarationParameters) ArrayList(java.util.ArrayList)

Aggregations

MethodDeclarationParameters (com.yahoo.aptutils.writer.parameters.MethodDeclarationParameters)7 DeclaredTypeName (com.yahoo.aptutils.model.DeclaredTypeName)2 Expression (com.yahoo.aptutils.writer.expressions.Expression)2 ModelMethod (com.yahoo.squidb.annotations.ModelMethod)1 RowidPropertyGenerator (com.yahoo.squidb.processor.plugins.defaults.properties.generators.RowidPropertyGenerator)1 ArrayList (java.util.ArrayList)1