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

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


                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,
                meta);
View Full Code Here


  public void testSynthesizeWriterOnClass() throws GeDAException {
   
    final TestDto1Class dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataWriter writerMyString = new JavassistMethodSynthesizer(this.getClass().getClassLoader()).synthesizeWriter(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto1Class.class, "myString",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto1Class.class)   
        )   
    );
   
    assertEquals(String.class, writerMyString.getParameterType());
    writerMyString.write(dto, "Goodbye");
    assertEquals("Goodbye", dto.getMyString());
   
  }
View Full Code Here

    final String methodName = writeMethod.getName();
   
    final String writerClassName = generateClassName("DataWriter", classNameFull, methodName);
   
   
    DataWriter writer;

    writer = getFromCacheOrCreateFromClassLoader(writerClassName, WRITER_CACHE, getClassLoader());
    if (writer == null) {
      writeLock.lock();
      final MakeContext ctx = new MakeContext(DataWriter.class.getCanonicalName());
View Full Code Here

    public DataWriter synthesizeWriter(final PropertyDescriptor descriptor) throws InspectionPropertyNotFoundException, UnableToCreateInstanceException, GeDARuntimeException {

        final String propName = descriptor.getName();
        final Class paramType = descriptor.getWriteMethod().getParameterTypes()[0];

        return new DataWriter() {

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

            public void write(final Object source, final Object value) {
View Full Code Here

      CtMethod methodGetParameterType = CtMethod.make(getParameterTypeMethodCode.toString(), ctClass);
      ctClass.addMethod(methodGetParameterType);
      ctClass.detach();
     
      final DataWriter writer = (DataWriter) ctClass.toClass(
          loader, DataWriter.class.getProtectionDomain()).newInstance();
     
      return writer;
     
    } catch (CannotCompileException cce) {
View Full Code Here

      argType = PRIMITIVE_TO_WRAPPER_CLASS.get(sourceClassSetterMethodArgumentClass.getCanonicalName());
    } else {
      argType = sourceClassSetterMethodArgumentClass;
    }
   
    return new DataWriter() {
     
      private final Method method = writeMethod;
      private final Class< ? > type = argType;

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

    public DataWriter synthesizeWriter(final PropertyDescriptor descriptor) throws InspectionPropertyNotFoundException, UnableToCreateInstanceException, GeDARuntimeException {

        final String propName = descriptor.getName();
        final Class paramType = descriptor.getWriteMethod().getParameterTypes()[0];

        return new DataWriter() {

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

            public void write(final Object source, final Object value) {
View Full Code Here

  public void testSynthesizeWriterOnClass() throws GeDAException {
   
    final TestDto1Class dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataWriter writerMyString = new BCELMethodSynthesizer(this.getClass().getClassLoader()).synthesizeWriter(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto1Class.class, "myString",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto1Class.class)   
        )   
    );
   
    assertEquals(String.class, writerMyString.getParameterType());
    writerMyString.write(dto, "Goodbye");
    assertEquals("Goodbye", dto.getMyString());
   
  }
View Full Code Here

  public void testSynthesizeWriterOnInterface() throws GeDAException {
   
    final TestDto1Interface dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataWriter writerMyString = new BCELMethodSynthesizer(this.getClass().getClassLoader()).synthesizeWriter(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto1Interface.class, "myString",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto1Interface.class)   
        )   
    );
   
    assertEquals(String.class, writerMyString.getParameterType());
    writerMyString.write(dto, "Goodbye");
    assertEquals("Goodbye", dto.getMyString());
   
  }
View Full Code Here

  public void testSynthesizeWriterOnInterface() throws GeDAException {
   
    final TestDto1Interface dto = new TestDto1Class();
    dto.setMyString("Hello");
   
    final DataWriter writerMyString = new JavassistMethodSynthesizer(this.getClass().getClassLoader()).synthesizeWriter(
        PropertyInspector.getDtoPropertyDescriptorForField(
            TestDto1Interface.class, "myString",
            PropertyInspector.getPropertyDescriptorsForClass(TestDto1Interface.class)   
        )   
    );
   
    assertEquals(String.class, writerMyString.getParameterType());
    writerMyString.write(dto, "Goodbye");
    assertEquals("Goodbye", dto.getMyString());
   
  }
View Full Code Here

TOP

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

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.