if (downstream.size() == 1) {
FragmentNode succ = downstream.iterator().next();
return succ.getName();
}
DataClass model = environment.getDataClasses().load(type);
if (model == null) {
throw new IllegalStateException(type.toString());
}
Type dataType = importer.toType(model.getType());
SimpleName cacheName = names.create("cache");
FieldDeclaration cache = factory.newFieldDeclaration(
null,
new AttributeBuilder(factory)
.Private()
.toAttributes(),
dataType,
cacheName,
model.createNewInstance(dataType));
SimpleName argumentName = names.create("arg");
List<Statement> statements = Lists.create();
Iterator<FragmentNode> iter = downstream.iterator();
while (iter.hasNext()) {
FragmentNode node = iter.next();
if (iter.hasNext()) {
statements.add(model.assign(cacheName, argumentName));
statements.add(new ExpressionBuilder(factory, node.getName())
.method(FlowElementProcessor.RESULT_METHOD_NAME, cacheName)
.toStatement());
} else {
statements.add(new ExpressionBuilder(factory, node.getName())
.method(FlowElementProcessor.RESULT_METHOD_NAME, argumentName)
.toStatement());
}
}
MethodDeclaration result = factory.newMethodDeclaration(
null,
new AttributeBuilder(factory)
.annotation(importer.toType(Override.class))
.Public()
.toAttributes(),
factory.newBasicType(BasicTypeKind.VOID),
factory.newSimpleName(FlowElementProcessor.RESULT_METHOD_NAME),
Collections.singletonList(factory.newFormalParameterDeclaration(
Models.toType(factory, model.getType()),
argumentName)),
statements);
return factory.newClassInstanceCreationExpression(
null,