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

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


        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 CollectionPipe(context,
                dtoFieldRead, dtoFieldWrite,
                entityFieldRead, entityFieldWrite,
View Full Code Here


  public void testSynthesizeReaderOnClass() throws GeDAException {
   
    final TestDto1Class dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataReader readerMyString = new JavassistMethodSynthesizer(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 JavassistMethodSynthesizer(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 JavassistMethodSynthesizer(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 JavassistMethodSynthesizer(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 JavassistMethodSynthesizer(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 String sourceClassNameFull = getValidDeclaringClass(readMethod).getCanonicalName();
    final String sourceClassGetterMethodName = readMethod.getName();
   
    final String readerClassName = generateClassName("DataReader", sourceClassNameFull, sourceClassGetterMethodName);
   
    DataReader reader;
   
    reader = getFromCacheOrCreateFromClassLoader(readerClassName, READER_CACHE, getClassLoader());
   
    if (reader == null) {
      readLock.lock();
View Full Code Here

    public DataReader synthesizeReader(final PropertyDescriptor descriptor) throws InspectionPropertyNotFoundException, UnableToCreateInstanceException, GeDARuntimeException {

        final String propName = descriptor.getName();
        final Class returnType = descriptor.getReadMethod().getReturnType();

        return new DataReader() {

            private String property = propName;
            private Class type = returnType;

            public Object read(final Object source) {
View Full Code Here

      returnType = Object.class; // generics
    } else {
      returnType = Object.class; // default
    }
   
    return new DataReader() {
     
      private final Method method = readMethod;
      private final Class< ? > type = returnType;

      public Class< ? > getReturnType() {
View Full Code Here

    public DataReader synthesizeReader(final PropertyDescriptor descriptor) throws InspectionPropertyNotFoundException, UnableToCreateInstanceException, GeDARuntimeException {

        final String propName = descriptor.getName();
        final Class returnType = descriptor.getReadMethod().getReturnType();

        return new DataReader() {

            private String property = propName;
            private Class type = returnType;

            public Object read(final Object source) {
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.