use of org.robobinding.codegen.presentationmodel.PresentationModelInfo in project RoboBinding by RoboBinding.
the class PresentationModelProcessor method createItemPresentationModelObjectSourceFiles.
private void createItemPresentationModelObjectSourceFiles(PresentationModelInfo presentationModelInfo, ProcessingContext context) throws JClassAlreadyExistsException, IOException {
for (DataSetPropertyInfo info : presentationModelInfo.dataSetProperties()) {
if (processedItemPresentationModels.contains(info.itemPresentationModelTypeName())) {
continue;
}
WrappedTypeElement typeElement = context.typeElementOf(info.itemPresentationModelTypeName());
PresentationModelInfoBuilder builder = new PresentationModelInfoBuilder(typeElement, info.itemPresentationModelObjectTypeName(), true);
PresentationModelInfo itemPresentationModelInfo = builder.build();
Logger log = typeElement.logger();
try {
ItemPresentationModelObjectClassGen gen = new ItemPresentationModelObjectClassGen(itemPresentationModelInfo);
run(gen);
gen.writeTo(createOutput());
log.info("ItemPresentationModel '" + itemPresentationModelInfo.getPresentationModelObjectTypeName() + "' generated.");
} catch (java.lang.NoClassDefFoundError e) {
RuntimeException error = new RuntimeException("an error occured when generating source code for '" + presentationModelInfo.getPresentationModelObjectTypeName() + "'", e);
log.error(error);
throw error;
}
processedItemPresentationModels.add(info.itemPresentationModelTypeName());
}
}
use of org.robobinding.codegen.presentationmodel.PresentationModelInfo in project RoboBinding by RoboBinding.
the class PresentationModelTest method whenProcessPresentationModel_thenGetExpectedResult.
@Test
public void whenProcessPresentationModel_thenGetExpectedResult() {
PresentationModelInfo result = processJavaFileOf(SelfDescribedPresentationModel.class);
assertThat(result.properties().size(), is(SelfDescribedPresentationModel.numProperties));
assertThat(result.dataSetProperties().size(), is(SelfDescribedPresentationModel.numDataSetProperties));
assertThat(result.eventMethods().size(), is(SelfDescribedPresentationModel.numEventMethods));
}
use of org.robobinding.codegen.presentationmodel.PresentationModelInfo in project RoboBinding by RoboBinding.
the class PresentationModelTest method shouldGetPresentationModelChangeSupportMethodIgnored.
@Test
public void shouldGetPresentationModelChangeSupportMethodIgnored() {
PresentationModelInfo result = processJavaFileOf(GetPresentationModelChangeSupportIgnored.class);
assertThat(result.properties().size(), is(0));
}
use of org.robobinding.codegen.presentationmodel.PresentationModelInfo in project RoboBinding by RoboBinding.
the class PresentationModelTest method shouldHierarchicalPresentationModelRecognized.
@Test
public void shouldHierarchicalPresentationModelRecognized() {
PresentationModelInfo result = processJavaFileOf(HierarchicalPresentationModel.class);
assertThat(result.properties().size(), is(HierarchicalPresentationModel.numProperties));
assertThat(result.eventMethods().size(), is(HierarchicalPresentationModel.numEventMethods));
}
use of org.robobinding.codegen.presentationmodel.PresentationModelInfo in project RoboBinding by RoboBinding.
the class PresentationModelProcessor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
RoundContext roundContext = new RoundContext(roundEnv, processingEnv.getTypeUtils(), processingEnv.getElementUtils(), processingEnv.getMessager());
Set<WrappedTypeElement> typeElements = roundContext.typeElementsAnnotatedWith(PresentationModel.class, new PresentationModelFilter());
for (WrappedTypeElement typeElement : typeElements) {
String presentationModelObjectTypeName = PresentationModelObjectLoader.getObjectClassName(typeElement.binaryName());
PresentationModelInfoBuilder builder = new PresentationModelInfoBuilder(typeElement, presentationModelObjectTypeName, true);
PresentationModelInfo presentationModelInfo = builder.build();
Logger log = typeElement.logger();
ProcessingContext context = new ProcessingContext(processingEnv.getTypeUtils(), processingEnv.getElementUtils(), processingEnv.getMessager());
try {
if (isItemPresentationModelAlso(typeElement)) {
createItemPresentationModelObjectSourceFiles(presentationModelInfo, context);
} else {
generateAllClasses(presentationModelInfo, context, log);
}
} catch (IOException e) {
log.error(e);
throw new RuntimeException(e);
} catch (JClassAlreadyExistsException e) {
log.error(e);
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
log.error(e);
throw new RuntimeException(e);
}
}
return true;
}
Aggregations