private List<Statement> createBodyForConstructor(
List<FormalParameterDeclaration> parameters,
NameGenerator names) {
assert parameters != null;
List<Statement> statements = Lists.create();
SimpleName builderName = names.create("builder");
statements.add(new TypeBuilder(factory, util.t(FlowPartDescription.Builder.class))
.newObject(factory.newClassLiteral(util.t(flowClass.getElement())))
.toLocalVariableDeclaration(util.t(FlowPartDescription.Builder.class),
builderName));
Expression[] arguments = new Expression[
flowClass.getInputPorts().size()
+ flowClass.getOutputPorts().size()
+ flowClass.getParameters().size()
];
for (OperatorPortDeclaration var : flowClass.getInputPorts()) {
SimpleName name = names.create(var.getName());
statements.add(new ExpressionBuilder(factory, builderName)
.method("addInput",
util.v(var.getName()),
factory.newSimpleName(var.getType().getReference()))
.toLocalVariableDeclaration(
util.toInType(var.getType().getRepresentation()),
name));
arguments[var.getParameterPosition()] = name;
}
for (OperatorPortDeclaration var : flowClass.getOutputPorts()) {
SimpleName name = names.create(var.getName());
Expression type = toExpression(var);
assert type != null;
statements.add(new ExpressionBuilder(factory, builderName)
.method("addOutput", util.v(var.getName()), type)
.toLocalVariableDeclaration(
util.toOutType(var.getType().getRepresentation()),
name));
arguments[var.getParameterPosition()] = name;
}
for (OperatorPortDeclaration var : flowClass.getParameters()) {
Expression type = toExpression(var);
SimpleName name = factory.newSimpleName(var.getName());
statements.add(new ExpressionBuilder(factory, builderName)
.method("addParameter",
util.v(var.getName()),
type,
name)
.toStatement());
arguments[var.getParameterPosition()] = name;
}
SimpleName descName = names.create("desc");
statements.add(new TypeBuilder(factory, getType(util.t(flowClass.getElement())))
.newObject(arguments)
.toLocalVariableDeclaration(util.t(FlowDescription.class), descName));
Expression resolver = new ExpressionBuilder(factory, factory.newThis())