How to dispatch multimethod on primitive types?

Viewed 282

I want my program act differently between primitive types and their wrapper classes, for example:

(defmulti try-type class)

(defmethod try-type Integer [arg]
  (println "Integer"))

(defmethod try-type Integer/TYPE [arg]
  (println "int"))

But it doesn't work, though i try Integer and int both

user=> (try-type (.intValue (int 2)))
Integer
nil
user=> (try-type  (int 2))
Integer
nil

So, is it possible to dispatch multimethod on primitive types?

======EDIT======

i was wrapping a google guava into clojure. There is a primitive library in it, such as Booleans, Dobules, Ints etc. They have some methods in common, so i want to try multimethod.

1 Answers
Related