I have renamed your example classes to make it more concrete:
public class Person {
String name;
Address address;
}
public class Address {
String street;
String city;
}
Here is an outline of what to do. You simply define a conversion function for each class, and then compose them hierarchically:
(defn address->clj [address]
{:street (.-street address)
city (.-city address)})
(defn person->clj [person]
{:name (.-name person)
address (address->clj (.-address person))})
Consider some sample data (NOTE: constructor details omitted)
(def addr-1 (Address. "123 Main St" "Anytown"))
(def person-1 (Person. "Joe Smith" addr-1))
(someClass->clj person-1) ; Convert Java person-1 obj
You will get a Clojure map back that looks like:
{:name "Joe Smith"
:address {:street "123 Main St"
:city "Anytown"}}
Update
If you are working with a Java bean, please see also: