Search in sources :

Example 6 with WrappedTypeElement

use of org.robobinding.codegen.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.

the class ItemPresentationModelObjectClassGenTest method createPresentationModelInfoFor.

private PresentationModelInfo createPresentationModelInfoFor(Class<?> type) {
    WrappedTypeElement typeElement = new AptTestHelper(compilation).typeElementOf(type);
    PresentationModelInfoBuilder builder = new PresentationModelInfoBuilder(typeElement, type.getName() + "_IPM", false);
    return new OrderedPresentationModelInfo(builder.build());
}
Also used : PresentationModelInfoBuilder(org.robobinding.codegen.presentationmodel.processor.PresentationModelInfoBuilder) WrappedTypeElement(org.robobinding.codegen.apt.element.WrappedTypeElement) AptTestHelper(org.robobinding.codegen.apt.element.AptTestHelper)

Example 7 with WrappedTypeElement

use of org.robobinding.codegen.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.

the class ViewBindingInfoBuilderTest method givenNotCustomViewBindingSubclass_whenBuildViewBindingInfo_thenThrowUnsupportedViewBindingError.

@Test(expected = RuntimeException.class)
public void givenNotCustomViewBindingSubclass_whenBuildViewBindingInfo_thenThrowUnsupportedViewBindingError() {
    WrappedTypeElement typeElement = typeElementOf(NotCustomViewBindingSubclass.class);
    ViewBindingInfoBuilder builder = new ViewBindingInfoBuilder(typeElement, viewBindingObjectTypeName);
    builder.build();
}
Also used : WrappedTypeElement(org.robobinding.codegen.apt.element.WrappedTypeElement) Test(org.junit.Test)

Example 8 with WrappedTypeElement

use of org.robobinding.codegen.apt.element.WrappedTypeElement 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;
}
Also used : ProcessingContext(org.robobinding.codegen.apt.ProcessingContext) WrappedTypeElement(org.robobinding.codegen.apt.element.WrappedTypeElement) IOException(java.io.IOException) Logger(org.robobinding.codegen.apt.Logger) RoundContext(org.robobinding.codegen.apt.RoundContext) JClassAlreadyExistsException(com.helger.jcodemodel.JClassAlreadyExistsException) PresentationModelInfo(org.robobinding.codegen.presentationmodel.PresentationModelInfo)

Example 9 with WrappedTypeElement

use of org.robobinding.codegen.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.

the class PresentationModelObjectClassGenTest method createPresentationModelInfoFor.

private PresentationModelInfo createPresentationModelInfoFor(Class<?> type) {
    WrappedTypeElement typeElement = new AptTestHelper(compilation).typeElementOf(type);
    PresentationModelInfoBuilder builder = new PresentationModelInfoBuilder(typeElement, type.getName() + "_PM", true);
    return new OrderedPresentationModelInfo(builder.build());
}
Also used : PresentationModelInfoBuilder(org.robobinding.codegen.presentationmodel.processor.PresentationModelInfoBuilder) WrappedTypeElement(org.robobinding.codegen.apt.element.WrappedTypeElement) AptTestHelper(org.robobinding.codegen.apt.element.AptTestHelper)

Example 10 with WrappedTypeElement

use of org.robobinding.codegen.apt.element.WrappedTypeElement in project RoboBinding by RoboBinding.

the class PresentationModelItemInfoProcessor method generateAllClasses.

@Override
protected void generateAllClasses(PresentationModelInfo presentationModelInfo, ProcessingContext context, Logger log) throws IOException, JClassAlreadyExistsException, ClassNotFoundException {
    DataSetPropertyInfo dataSetProperty = presentationModelInfo.dataSetProperties().toArray(new DataSetPropertyInfo[0])[0];
    WrappedTypeElement typeElement = context.typeElementOf(dataSetProperty.itemPresentationModelTypeName());
    PresentationModelInfoBuilder builder = new PresentationModelInfoBuilder(typeElement, dataSetProperty.itemPresentationModelObjectTypeName(), false);
    result = builder.build();
}
Also used : DataSetPropertyInfo(org.robobinding.codegen.presentationmodel.DataSetPropertyInfo) WrappedTypeElement(org.robobinding.codegen.apt.element.WrappedTypeElement)

Aggregations

WrappedTypeElement (org.robobinding.codegen.apt.element.WrappedTypeElement)10 Logger (org.robobinding.codegen.apt.Logger)3 JClassAlreadyExistsException (com.helger.jcodemodel.JClassAlreadyExistsException)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 RoundContext (org.robobinding.codegen.apt.RoundContext)2 AptTestHelper (org.robobinding.codegen.apt.element.AptTestHelper)2 DataSetPropertyInfo (org.robobinding.codegen.presentationmodel.DataSetPropertyInfo)2 PresentationModelInfo (org.robobinding.codegen.presentationmodel.PresentationModelInfo)2 PresentationModelInfoBuilder (org.robobinding.codegen.presentationmodel.processor.PresentationModelInfoBuilder)2 Theory (org.junit.experimental.theories.Theory)1 ProcessingContext (org.robobinding.codegen.apt.ProcessingContext)1 ItemPresentationModelObjectClassGen (org.robobinding.codegen.presentationmodel.ItemPresentationModelObjectClassGen)1