diff options
author | Stuart Sierra <mail@stuartsierra.com> | 2009-08-15 16:26:06 -0400 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2009-08-15 16:26:06 -0400 |
commit | c2f2b43fa22e3759a1844a1715fb8a32b18e9f6f (patch) | |
tree | d8e3801819e03cb810dea13d20ce014661e52a10 | |
parent | 94ce3fbbbc180e10fc8f5e4412f68f72cde938c6 (diff) |
java_utils.clj: added type hints to avoid reflection
-rw-r--r-- | src/clojure/contrib/java_utils.clj | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/clojure/contrib/java_utils.clj b/src/clojure/contrib/java_utils.clj index ea6ab90a..75e8ca8b 100644 --- a/src/clojure/contrib/java_utils.clj +++ b/src/clojure/contrib/java_utils.clj @@ -55,7 +55,7 @@ let me (Stu) and the Clojure community know via the mailing list. "} clojure.contrib.java-utils - (:import [java.io File] + (:import [java.io File FileOutputStream] [java.util Properties] [java.net URI URL])) @@ -64,28 +64,28 @@ Building block for clojure.contrib.java-utils/file." class) -(defmethod relative-path-string String [s] +(defmethod relative-path-string String [#^String s] (relative-path-string (File. s))) -(defmethod relative-path-string File [f] +(defmethod relative-path-string File [#^File f] (if (.isAbsolute f) (throw (IllegalArgumentException. (str f " is not a relative path"))) (.getPath f))) -(defmulti as-file +(defmulti #^File as-file "Interpret a String or a java.io.File as a File. Building block for clojure.contrib.java-utils/file, which you should prefer in most cases." class) -(defmethod as-file String [s] (File. s)) +(defmethod as-file String [#^String s] (File. s)) (defmethod as-file File [f] f) -(defn file +(defn #^File file "Returns a java.io.File from string or file args." ([arg] (as-file arg)) ([parent child] - (File. (as-file parent) (relative-path-string child))) + (File. #^File (as-file parent) #^String (relative-path-string child))) ([parent child & more] (reduce file (file parent child) more))) @@ -131,7 +131,7 @@ ; Not there is no corresponding props->map. Just destructure! -(defn as-properties +(defn #^Properties as-properties "Convert any seq of pairs to a java.utils.Properties instance. Uses as-str to convert both keys and values into strings." {:tag Properties} @@ -153,9 +153,9 @@ {:tag Properties} ([m file-able] (write-properties m file-able nil)) ([m file-able comments] - (with-open [f (java.io.FileOutputStream. (file file-able))] + (with-open [#^FileOutputStream f (FileOutputStream. (file file-able))] (doto (as-properties m) - (.store f comments))))) + (.store f #^String comments))))) (defmulti #^{:doc "Coerces argument (URL, URI, or String) to a java.net.URL." |