I do a serializer-deserializer in xml. I have such a class in some package

@XMLAlias("organization") public static class Organization{ ... } 

Annotation code:

 @Target({ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface XMLAlias { String value(); } 

Correspondingly, if the abstract is present in the serializer code, the class name in the final xml document is replaced with the annotation value, in this case <organization> . I can’t figure out how to deserialize me to find in runtime the original class name (which consists of a package + the class name itself),

  • I apologize for the offtopic, but is this some kind of test task or personal interest? just for this purpose JAXB - I. Perevoz
  • Do you want to find the class name test.Organization by the value of the XMLAlias annotation XMLAlias ? - Regent
  • @Regent Like that) Hope this is possible. - KnockKnock
  • @Evgenb as far as I understand, for this you need to look through all the available classes. In order not to reinvent the wheel, you can use Google reflections . This library has a getTypesAnnotatedWith method that returns a set of classes that have this annotation. Here among this set and you will need to search. I have never used this library, so I cannot give a complete answer. - Regent
  • @Regent thanks) because I didn't even know where to dig - KnockKnock

0