extend CanonicalByteArray support for numbers
java.mathBigDecimal, java.mathBigInteger, clojure.lang.BigInt
This commit is contained in:
parent
ff1d4b7f12
commit
284dcc0eae
@ -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
|
||||
@ -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] (long->bytes (Double/doubleToLongBits (double this))))
|
||||
BigInteger
|
||||
(to-byte-array [this] (long->bytes (Double/doubleToLongBits (double 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user