It occurs to me that the "unbean" function could be very useful when writing tests for code that calls Java objects. Anyone have thoughts on its use in this way?
On Feb 24, 9:18 pm, ".Bill Smith" <william.m.sm...@gmail.com> wrote: > > I tend to associate "bean" with Java beans, so the naming seems to be > > reversed IMHO: "bean" should convert a Clojure map to a Java bean, and > > "unbean" should do the reverse. > > Agreed the name is awkward. > > > It's getting late here so I don't have time to test, but would a > > recursive map be converted to a recursive bean (i.e. some elements are > > themselves beans) and vice versa with your functions? > > The map alone is not sufficient to describe the object; you need the > class too. That's true both for the bean and any of it's bean-typed > properties, since a property might be typed with an interface or an > abstract class for which there is no constructor. To specify the > value of a bean-typed property, you'd do something like this: > > (unbean House {:address "100 Elm Street" :architecture (unbean > Architecture {:style "Tudor Revival" :architect "F L Wright" :material > "concrete"})}) > > Of course the bean function doesn't walk the object hierarchy either. > > Thanks for the feedback. > Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---