Advertisement
Guest User

Untitled

a guest
Sep 21st, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. Java Interface
  2. public interface TaGrpService {
  3. public void execute(String group, Set<CoreMetaData> set) throws Exception;
  4. }
  5.  
  6.  
  7. Clojure Proxy and Implementation of body
  8. (def group-service (proxy [TaGrpService] []
  9. (execute [group set]
  10. (print-group group set))))
  11.  
  12. ;; HERE I WANT TO PRINT THE GROUP AND THE CHILDREN IN THE SET s
  13. (defn print-group [group s]
  14. (prn (str "Group: " group))
  15. (for [x s]
  16. (prn (str " " (.name (.getFuncInfo x))))
  17. ))
  18.  
  19. ; How i execute the service, an internal function takes the implementation of inteface and does work.
  20. (CoreMetaData/forEachGrp group-service)
  21.  
  22. ;; OUTPUT
  23. (CoreMetaData/forEachGrp group-service)
  24. "Group: Cycle Indicators"
  25. "Group: Math Operators"
  26. "Group: Math Transform"
  27. "Group: Momentum Indicators"
  28. "Group: Overlap Studies"
  29. "Group: Pattern Recognition"
  30. "Group: Price Transform"
  31. "Group: Statistic Functions"
  32. "Group: Volatility Indicators"
  33. "Group: Volume Indicators"
  34. nil
  35.  
  36.  
  37.  
  38. ;; IF I CHANGE IMPLEMENTATION OF print-group to...
  39. (defn print-group [group functions]
  40. (prn [(class group) (class functions)])
  41. )
  42. OUTPUT IS:
  43. [java.lang.String java.util.TreeSet]
  44. --snip---
  45. [java.lang.String java.util.TreeSet]
  46. nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement