throw new IllegalStateException(MessageFormat.format(
"Internal Error: joined model {0} has no JoinTrait", //$NON-NLS-1$
model.getName()));
}
ModelFactory f = context.getModelFactory();
List<Annotation> eTerms = Lists.create();
for (ReduceTerm<?> term : trait.getTerms()) {
ClassLiteral source = f.newClassLiteral(context.resolve(term.getSource()));
ArrayInitializer mappings = toMappings(context, term.getMappings());
Annotation shuffle = toKey(context, term);
eTerms.addAll(new AttributeBuilder(f)
.annotation(context.resolve(Joined.Term.class),
"source", source, //$NON-NLS-1$
"mappings", mappings, //$NON-NLS-1$
"shuffle", shuffle) //$NON-NLS-1$
.toAnnotations());
}
return new AttributeBuilder(f)
.annotation(context.resolve(Joined.class),
"terms", f.newArrayInitializer(eTerms)) //$NON-NLS-1$
.toAnnotations();
}