change the method name

This commit is contained in:
Gered 2014-03-02 09:26:13 -05:00
parent b3fb3d6e58
commit 384c3926ee

View file

@ -1,51 +1,51 @@
(ns clj-jtwig.convert) (ns clj-jtwig.convert)
(defprotocol JavaToClojure (defprotocol JavaToClojure
(convert [x])) (to-clojure [x]))
(extend-protocol JavaToClojure (extend-protocol JavaToClojure
java.util.Collection java.util.Collection
(convert [x] (to-clojure [x]
(map convert x)) (map to-clojure x))
java.util.Map java.util.Map
(convert [x] (to-clojure [x]
(->> x (->> x
(.entrySet) (.entrySet)
(reduce (reduce
(fn [m [k v]] (fn [m [k v]]
; TODO: perhaps we should be doing (keyword k) instead? i don't like that it technically is not an ; TODO: perhaps we should be doing (keyword k) instead? i don't like that it technically is not an
; exact conversion if we do it that way though, even if it is more idiomatic for clojure ... ; exact conversion if we do it that way though, even if it is more idiomatic for clojure ...
(assoc m k (convert v))) (assoc m k (to-clojure v)))
{}))) {})))
java.lang.Number java.lang.Number
(convert [x] (to-clojure [x]
x) x)
java.lang.Boolean java.lang.Boolean
(convert [x] (to-clojure [x]
x) x)
java.lang.Character java.lang.Character
(convert [x] (to-clojure [x]
x) x)
java.lang.String java.lang.String
(convert [x] (to-clojure [x]
x) x)
java.lang.Object java.lang.Object
(convert [x] (to-clojure [x]
(-> x (-> x
(bean) ; TODO: this is definitely not the fastest method ... (bean) ; TODO: this is definitely not the fastest method ...
(dissoc :class))) (dissoc :class)))
nil nil
(convert [_] (to-clojure [_]
nil)) nil))
(defn java->clojure (defn java->clojure
"converts a java value to an equivalent value using one of the clojure data types" "converts a java value to an equivalent value using one of the clojure data types"
[x] [x]
(convert x)) (to-clojure x))