Skip to content

Commit

Permalink
Extend Decodeable to j.u.ArrayList to preserve roundtrip ILookup sema…
Browse files Browse the repository at this point in the history
…ntics
  • Loading branch information
johnchapin committed Jul 1, 2014
1 parent 1be1339 commit 147fd39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/src/main/clojure/vertx/utils.clj
Expand Up @@ -18,7 +18,7 @@
(:import [org.vertx.java.core.json JsonArray JsonObject]
[clojure.lang BigInt IPersistentMap Ratio Seqable IPersistentVector
IPersistentList IPersistentSet IPersistentCollection Associative Keyword ISeq]
[java.util Map UUID List Map$Entry]
[java.util ArrayList Map UUID List Map$Entry]
[java.net NetworkInterface InetAddress InetSocketAddress]
java.math.BigDecimal))

Expand Down Expand Up @@ -106,7 +106,10 @@
(assoc m
(keyword (.getKey e))
(decode (.getValue e))))
{} (seq data))))
{} (seq data)))
ArrayList
(decode [data]
(vec (map decode data))))

(defn uuid
"Generates a uuid."
Expand Down
5 changes: 5 additions & 0 deletions api/src/test/clojure/vertx/utils_test.clj
Expand Up @@ -74,3 +74,8 @@
(deftest map-of-mapped-nums-should-decode
(is (= {:a {:b 1000000000000} } (decode (JsonObject. "{\"a\":{\"b\":1000000000000}}")))))

(deftest ilookup-semantics-should-hold
(let [data {:a {:b ["foo" "bar"]}}
ks [:a :b 0]]
(is (= (get-in data ks)
(get-in (-> data encode decode) ks)))))

0 comments on commit 147fd39

Please sign in to comment.