The "payload" variable should always be a single item. It is reasonable
for this safeguard to exist within the method itself.
On 10/07/2015 08:54 AM, Ondrej Zizka wrote:
Just a minor thing, for potential refactoring:
TopLayerSingletonFramesSelector:
public Iterable<? extends WindupVertexFrame> getFrames(GraphRewrite
event, EvaluationContext context)
{
Variables variables = Variables.instance(event);
this.varName = Iteration.getPayloadVariableName(event, context);
return variables.findVariable(varName);
}
public static String getPayloadVariableName(GraphRewrite event,
EvaluationContext ctx) throws IllegalStateException
{
Variables variables = Variables.instance(event);
Map<String, Iterable<? extends WindupVertexFrame>> topLayer =
variables.peek();
if (topLayer.keySet().size() != 1)
throw new IllegalStateException("Cannot determine Iteration
payload variable name because the top "
+ "layer of " + Variables.class.getSimpleName() + "
stack contains no or multiple variables: " + topLayer.keySet());
String name = topLayer.keySet().iterator().next();
return name;
}
So it verifies that the Variables stack has only one name, then returns
it to let the calling code return the content of that single variable.
I think the logic should be reversed - the check for a single variable
should be in the calling code.
Ondra
_______________________________________________
windup-dev mailing list
windup-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/windup-dev