1 Reply Latest reply on Oct 12, 2012 7:25 AM by werrenmi

    Marshaller and Generics

    werrenmi

      Hello together

       

      I have a hard problem with marshalling parametrited types. I try to bring the following example to work.

       

       

      public interface MyInterface<T>{

           ...

           public T getValue();

           public void setValue(T value);

           ...

      }

       

      public abstract class MyAbstractClass<T> implements MyInterface<T>{

           ...

           private T value;

       

           protected MyAbstractClass(..., T value, ...){

                this.value = value;

           }

       

           public T getValue() {

                return value;

           }

           public void setValue(T value) {

                this.value = value;

           }

           ...

      }

       

      @Portable

      public class MyConcreteClass extends MyAbstractClass<T> {

           public MyConcreteClass(..., T value, ...){

                super(..., T value, ...);

           }

      }

       

       

      @Portable

      public class Dto {

       

           private MyConcreteClass<ValueTypeOne> firstDtoField;

           private MyConcreteClass<ValueTypeTwo> secondDtoField;

       

           ....

      }

       

       

      I tried with a @CustomMapper but the problem is, that it seem that this mapper will be executed for each reference declaration of MyConcreteClass, because they have a different generic parameter. I dont how i can access the information about this Generics information per declaration via MappingDefinition.

       

      Is there a way to get this information, or is this kind of implementation not possible?

       

      thanks in advance.

       

      Greez Michel

        • 1. Re: Marshaller and Generics
          werrenmi

          Okay i found a solution.

           

          The problem occurrs since i declare a field, thats typed with "MyConcreteClass". The solution is to use the constructor initialize definition with "@MapsTo".