Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public static Map<String, Human> getBeans(List<Method> methods) throws Exception {
  2. Map<String, Human> ans = new HashMap<>();
  3.  
  4. if (methods.isEmpty()) return ans;
  5.  
  6. for (Method i : methods) {
  7. String annotation = i.getAnnotation(Annot.class).value();
  8. if (annotation.isEmpty()) {
  9. ans.put(i.getName(), (Human) i.invoke(null, ans.get(annotation)));
  10. }
  11. }
  12.  
  13.  
  14. for (int i = 0; i < methods.size() - 1; i++) {
  15. for (int j = i; j < methods.size(); j++) {
  16. String annotation = methods.get(j).getAnnotation(Annot.class).value();
  17. if(ans.containsKey(methods.get(j).getName())) continue;
  18.  
  19. if (!annotation.isEmpty() && ans.containsKey(annotation) ){
  20. ans.put(methods.get(j).getName(),
  21. (Human) methods.get(j).invoke(null, ans.get(annotation)));
  22. }
  23. }
  24. }
  25.  
  26. return ans;
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement