Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/valuehash/impl.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns valuehash.impl
"Simple implementation based on plain byte arrays"
(:import [java.util UUID Date]))
(:import [java.util UUID Date]
[java.math BigDecimal BigInteger]))

(defprotocol CanonicalByteArray
"An object that can be converted to a canonical byte array, with value
Expand Down Expand Up @@ -64,6 +65,12 @@
(to-byte-array [this] (long->bytes (Double/doubleToLongBits this)))
clojure.lang.Ratio
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double this))))
clojure.lang.BigInt
(to-byte-array [this] (.toByteArray (.toBigInteger this)))
BigInteger
(to-byte-array [this] (.toByteArray this))
BigDecimal
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double this))))
Boolean
(to-byte-array [this] (byte-array 1 (if this (byte 1) (byte 0))))
Character
Expand Down