argument)),
statements);
}
private MethodDeclaration createCopier() {
SimpleName argument = factory.newSimpleName("original");
List<Statement> cases = Lists.create();
for (List<Segment> segments : ShuffleEmiterUtil.groupByElement(model)) {
for (Segment segment : segments) {
cases.add(factory.newSwitchCaseLabel(v(segment.getPortId())));
}
Segment segment = segments.get(0);
for (Term term : segment.getTerms()) {
if (term.getArrangement() != Arrangement.GROUPING) {
continue;
}
String name = ShuffleEmiterUtil.getPropertyName(segment, term);
cases.add(term.getSource().assign(
new ExpressionBuilder(factory, factory.newThis())
.field(name)
.toExpression(),
new ExpressionBuilder(factory, argument)
.field(name)
.toExpression()));
}
cases.add(factory.newBreakStatement());
}
cases.add(factory.newSwitchDefaultLabel());
cases.add(new TypeBuilder(factory, t(AssertionError.class))
.newObject(new ExpressionBuilder(factory, factory.newThis())
.field(factory.newSimpleName(PORT_ID_FIELD_NAME))
.assignFrom(new ExpressionBuilder(factory, argument)
.field(factory.newSimpleName(PORT_ID_FIELD_NAME))
.toExpression())
.toExpression())
.toThrowStatement());
SimpleName typeName = factory.newSimpleName(Naming.getShuffleKeyClass());
List<Statement> statements = Lists.create();
statements.add(new ExpressionBuilder(factory, factory.newThis())
.field(factory.newSimpleName(PORT_ID_FIELD_NAME))
.assignFrom(new ExpressionBuilder(factory, argument)
.field(factory.newSimpleName(PORT_ID_FIELD_NAME))