(require '[clojure.reflect]
'[clojure.java.io :as io])
(->> (clojure.reflect/reflect java.nio.file.Paths)
:members)
#_#{{:name java.nio.file.Paths,
:declaring-class java.nio.file.Paths,
:parameter-types [],
:exception-types [],
:flags #{:private}}
{:name get,
:return-type java.nio.file.Path,
:declaring-class java.nio.file.Paths,
:parameter-types [java.lang.String java.lang.String<>],
:exception-types [],
:flags #{:varargs :public :static}}
{:name get,
:return-type java.nio.file.Path,
:declaring-class java.nio.file.Paths,
:parameter-types [java.net.URI],
:exception-types [],
:flags #{:public :static}}}
(java.nio.file.Paths/get "/usr" (into-array String ["bin" "perl"]))
(java.nio.file.Paths/get (java.net.URI. "file:///usr/bin/perl"))
;;; mv, mkdir, cp とか 基本的な Unix コマンドに対応する様なものがある
;;; そうじゃないものあるけど
;;; 引数は基本的に java.nio.file.Path
(->> (clojure.reflect/reflect java.nio.file.Files)
:members
(remove #((:flags %) :private))
(remove :type) ;remove variables
;; (filter #(= 'java.nio.file.Path (-> % :parameter-types first)))
#_(filter #(and (= 'java.nio.file.Path (get-in % [:parameter-types 0]))
(= 'java.nio.file.Path (get-in % [:parameter-types 1]))))
;; (map :name)
;; distinct
;; sort
)
;;; 出来なかった
(comment
(java.nio.file.Files/walkFileTree
(java.nio.file.Paths/get "/etc" (into-array String []))
(fn [p a]))
(with-open [r (io/reader "/etc/passwd")]
(-> r
.lines
(.forEach println)))
(with-open [r (io/reader "/etc/passwd")]
(-> r
.lines
(.forEach System.out.p)))
)