private void validateExistingRolesPresent(final Collection<MetaClass> pages,
final Multimap<Class<?>, MetaClass> pageRoles) {
for (final MetaClass page : pages) {
for (final MetaField field : getAllFields(page)) {
if (field.getType().getErased().equals(MetaClassFactory.get(TransitionToRole.class))) {
final MetaType uniquePageRole = field.getType().getParameterizedType().getTypeParameters()[0];
try {
getPageWithRole(uniquePageRole, pageRoles);
}
catch (IllegalStateException e) {
// give a more descriptive error message.
throw new GenerationException("No @Page with the UniquePageRole " + uniquePageRole.getName()
+ " exists to satisfy TransitionToRole<" + uniquePageRole.getName()
+ "> in " + page.getFullyQualifiedName() + "."
+ "\nThere must be exactly 1 @Page with this role.", e);
}
}
}