avoid reflection

This commit is contained in:
Mike Blume 2015-03-15 22:28:44 -07:00
parent ee227d7cd1
commit c97f9a3a9d

View file

@ -2,15 +2,16 @@
(deftype SqlCall [name args _meta] (deftype SqlCall [name args _meta]
Object Object
(hashCode [this] (hash-combine (hash name) (hash args))) (hashCode [_] (hash-combine (hash name) (hash args)))
(equals [this x] (equals [this x]
(cond (identical? this x) true (cond (identical? this x) true
(instance? SqlCall x) (and (= (.name this) (.name x)) (instance? SqlCall x) (let [^SqlCall x x]
(= (.args this) (.args x))) (and (= name (.name x))
(= args (.args x))))
:else false)) :else false))
clojure.lang.IObj clojure.lang.IObj
(meta [this] _meta) (meta [_] _meta)
(withMeta [this m] (SqlCall. (.name this) (.args this) m))) (withMeta [_ m] (SqlCall. name args m)))
(defn call (defn call
"Represents a SQL function call. Name should be a keyword." "Represents a SQL function call. Name should be a keyword."
@ -32,10 +33,10 @@
(deftype SqlRaw [s _meta] (deftype SqlRaw [s _meta]
Object Object
(hashCode [this] (hash-combine (hash (class this)) (hash s))) (hashCode [this] (hash-combine (hash (class this)) (hash s)))
(equals [this x] (and (instance? SqlRaw x) (= (.s this) (.s x)))) (equals [_ x] (and (instance? SqlRaw x) (= s (.s ^SqlRaw x))))
clojure.lang.IObj clojure.lang.IObj
(meta [this] _meta) (meta [_] _meta)
(withMeta [this m] (SqlRaw. (.s this) m))) (withMeta [_ m] (SqlRaw. s m)))
(defn raw (defn raw
"Represents a raw SQL string" "Represents a raw SQL string"
@ -57,10 +58,10 @@
(deftype SqlParam [name _meta] (deftype SqlParam [name _meta]
Object Object
(hashCode [this] (hash-combine (hash (class this)) (hash (name name)))) (hashCode [this] (hash-combine (hash (class this)) (hash (name name))))
(equals [this x] (and (instance? SqlParam x) (= (.name this) (.name x)))) (equals [_ x] (and (instance? SqlParam x) (= name (.name ^SqlParam x))))
clojure.lang.IObj clojure.lang.IObj
(meta [this] _meta) (meta [_] _meta)
(withMeta [this m] (SqlParam. (.name this) m))) (withMeta [_ m] (SqlParam. name m)))
(defn param (defn param
"Represents a SQL parameter which can be filled in later" "Represents a SQL parameter which can be filled in later"