2 Replies Latest reply on May 13, 2008 11:57 AM by Eugen Okon

    how to annotate a field

    Eugen Okon Newbie

      Firstly hello everybody!
      I am very new to javassist and am trying to write a class / function, which implements an interface which is passed to it.
      So its something like
      MyInterfac p = ImplFactory.implement(MyInterface.class);

      What i need is to annotate the field of the implemented class with annotations, which i have read from the interface.
      Bsp.:
      Interface:
      public interface PersonTestInterface {

      public static final String foaf = "http://xmlns.com/foaf/0.1/";

      @rdf(foaf+"surname") <-----take this
      public Collection getSurnames();
      }

      should be implemented as:

      public class PersonTestInterfaceImpl
      implements PersonTestInterface
      {
      @rdf(foaf+"surname") <---- put it here
      private Collection surnames;
      public Collection getSurnames()
      {
      return surnames;
      }
      }
      Could someone help me and tell how to create the annotations on the fields? The easiest way would be somethink to "copy" the annotations.

      Eugen