Package com.inspiresoftware.lib.dto.geda.assembler.extension

Examples of com.inspiresoftware.lib.dto.geda.assembler.extension.DataReader


            Object newDto = this.meta.newDtoBean(dtoBeanFactory);

            try {
                Assembler assembler = null;
                DataReader keyRead = null;

                for (Object object : entities) {

                    assembler = lazyCreateAssembler(assembler, newDto, object, dtoBeanFactory);
                    keyRead = lazyCollectionKeyRead(keyRead, newDto, object, dtoBeanFactory);
                  final Object key = keyRead.read(object);
                    assembler.assembleDto(newDto, object, converters, dtoBeanFactory);
                    dtos.put(key, newDto);

                    newDto = this.meta.newDtoBean(dtoBeanFactory);
                }
View Full Code Here


  public void testSynthesizeReaderOnClass() throws GeDAException {
   
    final TestDto1Class dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataReader readerMyString = new BCELMethodSynthesizer(this.getClass().getClassLoader()).synthesizeReader(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto1Class.class, "myString",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto1Class.class)   
        )   
    );
   
    assertEquals("Hello", readerMyString.read(dto));
    assertEquals(String.class, readerMyString.getReturnType());
   
  }
View Full Code Here

  public void testSynthesizeReaderOnClassOnPrimitive() throws GeDAException {
   
    final TestEntity3Class dto = new TestEntity3Class();
    dto.setDecision(true);
   
    final DataReader readerMyString = new BCELMethodSynthesizer(this.getClass().getClassLoader()).synthesizeReader(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestEntity3Class.class, "decision",
            PropertyInspector.getPropertyDescriptorsForClass(TestEntity3Class.class)   
        )   
    );
   
    assertTrue((Boolean) readerMyString.read(dto));
    assertEquals(Boolean.class, readerMyString.getReturnType());
   
  }
View Full Code Here

  public void testSynthesizeReaderOnInterface() throws GeDAException {
   
    final TestDto1Interface dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataReader readerMyString = new BCELMethodSynthesizer(this.getClass().getClassLoader()).synthesizeReader(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto1Interface.class, "myString",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto1Interface.class)   
        )   
    );
   
    assertEquals("Hello", readerMyString.read(dto));
    assertEquals(String.class, readerMyString.getReturnType());
   
  }
View Full Code Here

  @Test
  public void testSynthesizeReaderOnCollectionReturnType() throws GeDAException {
   
    final TestDto12CollectionClass dto = new TestDto12CollectionClass();
   
    final DataReader readerMyString = new BCELMethodSynthesizer(this.getClass().getClassLoader()).synthesizeReader(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto12CollectionClass.class, "items",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto12CollectionClass.class)   
        )   
    );
   
    assertNull(readerMyString.read(dto));
    assertEquals(Collection.class, readerMyString.getReturnType());
   
  }
View Full Code Here

  @Test
  public void testSynthesizeReaderOnMapReturnType() throws GeDAException {
   
    final TestDto12MapToMapClass dto = new TestDto12MapToMapClass();
   
    final DataReader readerMyString = new BCELMethodSynthesizer(this.getClass().getClassLoader()).synthesizeReader(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto12MapToMapClass.class, "items",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto12MapToMapClass.class)   
        )   
    );
   
    assertNull(readerMyString.read(dto));
    assertEquals(Map.class, readerMyString.getReturnType());
   
  }
View Full Code Here

        final PropertyDescriptor dtoFieldDesc = PropertyInspector.getDtoPropertyDescriptorForField(
                dtoClass, meta.getDtoFieldName(), dtoPropertyDescriptors);

        final MethodSynthesizer synthesizer = context.getMethodSynthesizer();

        final DataReader dtoFieldRead = meta.isReadOnly() ? null : synthesizer.synthesizeReader(dtoFieldDesc);
        final DataWriter dtoFieldWrite = synthesizer.synthesizeWriter(dtoFieldDesc);


        final boolean isMapEntity = Map.class.isAssignableFrom(entityClass);
        final boolean isListEntity = !isMapEntity && List.class.isAssignableFrom(entityClass);

        final MethodSynthesizer entitySynthesizer;
        final PropertyDescriptor entityFieldDesc;

        if (isMapEntity || isListEntity) {
            if (isMapEntity) {
                entitySynthesizer = mapSynthesizer;
            } else {
                entitySynthesizer = listSynthesizer;
            }
            entityFieldDesc = dtoFieldDesc;
        } else {
            entitySynthesizer = synthesizer;
            entityFieldDesc = PropertyInspector.getEntityPropertyDescriptorForField(
            dtoClass, entityClass, meta.getDtoFieldName(), meta.getEntityFieldName(), entityPropertyDescriptors);
        }

    final DataReader entityFieldRead = entitySynthesizer.synthesizeReader(entityFieldDesc);
    final DataWriter entityFieldWrite = meta.isReadOnly() ? null : entitySynthesizer.synthesizeWriter(entityFieldDesc);

        return new MapPipe(context,
                dtoFieldRead, dtoFieldWrite,
                entityFieldRead, entityFieldWrite,
View Full Code Here

            entitySynthesizer = synthesizer;
            entityFieldDesc = PropertyInspector.getEntityPropertyDescriptorForField(
        dtoClass, entityClass, meta.getDtoFieldName(), meta.getEntityFieldName(), entityPropertyDescriptors);
        }
   
    final DataReader dtoParentReadMethod;
   

    if (meta.isChild()) {
      final Method parentGet = dtoFieldDesc.getReadMethod();
View Full Code Here

  public void testSynthesizeReaderOnClass() throws GeDAException {
   
    final TestDto1Class dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataReader readerMyString = new SunJavaToolsMethodSynthesizer(this.getClass().getClassLoader(), WORKING_DIRECTORY).synthesizeReader(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto1Class.class, "myString",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto1Class.class)   
        )   
    );
   
    assertEquals("Hello", readerMyString.read(dto));
    assertEquals(String.class, readerMyString.getReturnType());
   
  }
View Full Code Here

  public void testSynthesizeReaderOnClassOnPrimitive() throws GeDAException {
   
    final TestEntity3Class dto = new TestEntity3Class();
    dto.setDecision(true);
   
    final DataReader readerMyString = new SunJavaToolsMethodSynthesizer(this.getClass().getClassLoader(), WORKING_DIRECTORY).synthesizeReader(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestEntity3Class.class, "decision",
            PropertyInspector.getPropertyDescriptorsForClass(TestEntity3Class.class)   
        )   
    );
   
    assertTrue((Boolean) readerMyString.read(dto));
    assertEquals(Boolean.class, readerMyString.getReturnType());
   
  }
View Full Code Here

TOP

Related Classes of com.inspiresoftware.lib.dto.geda.assembler.extension.DataReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.