for (MetaClass pageClass : pages) {
if (!pageClass.isAssignableTo(IsWidget.class)) {
throw new GenerationException(
"Class " + pageClass.getFullyQualifiedName() + " is annotated with @Page, so it must implement IsWidget");
}
Page annotation = pageClass.getAnnotation(Page.class);
String pageName = getPageName(pageClass);
List<Class<? extends PageRole>> annotatedPageRoles = Arrays.asList(annotation.role());
MetaClass prevPageWithThisName = pageNames.put(pageName, pageClass);
if (prevPageWithThisName != null) {
throw new GenerationException(
"Page names must be unique, but " + prevPageWithThisName + " and " + pageClass +
" are both named [" + pageName + "]");
}
Statement pageImplStmt = generateNewInstanceOfPageImpl(pageClass, pageName);
if (annotatedPageRoles.contains(DefaultPage.class)) {
// need to assign the page impl to a variable and add it to the map twice
URLPattern pattern = URLPatternMatcher.generatePattern(annotation.path());
if(pattern.getParamList().size() > 0) {
throw new GenerationException("Default Page must not contain any path parameters.");
}
ctor.append(Stmt.declareFinalVariable("defaultPage", PageNode.class, pageImplStmt));
pageImplStmt = Variable.get("defaultPage");