use of org.robobinding.codegen.apt.element.WrappedTypeElement 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.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.
the class ViewBindingInfoBuilder method build.
public ViewBindingInfo build() {
WrappedTypeElement viewType = extractViewType();
List<SimpleOneWayPropertyInfo> simpleOneWayPropertyInfoList = extractSimpleOneWayPropertyInfoList(viewType);
return new ViewBindingInfo(typeElement.qName(), viewBindingObjectTypeName, viewType, simpleOneWayPropertyInfoList);
}
use of org.robobinding.codegen.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.
the class ViewBindingProcessor 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(ViewBinding.class, new ViewBindingFilter());
for (WrappedTypeElement typeElement : typeElements) {
String viewBindingObjectTypeName = ViewBindingLoader.getViewBindingClassName(typeElement.binaryName());
ViewBindingInfoBuilder builder = new ViewBindingInfoBuilder(typeElement, viewBindingObjectTypeName);
ViewBindingInfo info = builder.build();
Logger log = typeElement.logger();
try {
generateViewBindingObjectSourceFile(info, 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;
}
use of org.robobinding.codegen.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.
the class ViewBindingInfoBuilderTest method givenValidImageViewBinding_whenBuildViewBindingInfo_thenReturnExpectedResult.
@Test
public void givenValidImageViewBinding_whenBuildViewBindingInfo_thenReturnExpectedResult() {
WrappedTypeElement typeElement = typeElementOf(ViewBindingWithVariousProperties.class);
ViewBindingInfoBuilder builder = new ViewBindingInfoBuilder(typeElement, viewBindingObjectTypeName);
ViewBindingInfo viewBindingInfo = builder.build();
ViewBindingInfo expectedViewBindingInfo = new ViewBindingInfo(ViewBindingWithVariousProperties.class.getName(), viewBindingObjectTypeName, typeElementOf(ViewWithProperties.class), Lists.newArrayList(new SimpleOneWayPropertyInfo(looseSetterOf(ViewWithProperties.PRIMITIVE_PROP)), new SimpleOneWayPropertyInfo(looseSetterOf(ViewWithProperties.OBJECT_PROP))));
Assert.assertThat(viewBindingInfo, equalTo(expectedViewBindingInfo));
}
use of org.robobinding.codegen.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.
the class ViewBindingInfoBuilderTest method givenInvalidViewBinding_whenBuildViewBindingInfo_thenThrowBindingPropertyCreationError.
@Theory
public void givenInvalidViewBinding_whenBuildViewBindingInfo_thenThrowBindingPropertyCreationError(@FromDataPoints("invalidViewBindings") Class<?> invalidViewBinding) {
WrappedTypeElement typeElement = typeElementOf(invalidViewBinding);
ViewBindingInfoBuilder builder = new ViewBindingInfoBuilder(typeElement, viewBindingObjectTypeName);
thrownException.expect(OneWayBindingPropertyGenerationException.class);
builder.build();
}
Aggregations