Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. @Target({ElementType.TYPE_USE,ElementType.TYPE_PARAMETER})
  2. public @interface TemplateCollection {
  3. String key() default "";
  4. }
  5.  
  6. List<Message> messages = new @TemplateCollection(key = "Chapters") ArrayList<>();
  7. messages.add(new Message("title1", "content1"));
  8. messages.add(new Message("title2", "content2"));
  9.  
  10. ArrayList<Chapter> res = Mapper.map((List)messages);
  11.  
  12. public static ArrayList<Chapter> map(Object object) throws SerializationException {
  13.  
  14. try {
  15. Class<?> demoClassObj = object.getClass();
  16. Annotation[] annotations = demoClassObj.getAnnotations(); <<< always Zero
  17.  
  18. return null;
  19.  
  20. } catch (Exception e) {
  21. throw new SerializationException(e.getMessage());
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement