(apply-element obj method args)
apply the class element to arguments
(->> (apply-element "123" "value" []) (map char)) => [ ]
apply the class element to arguments (->> (apply-element "123" "value" []) (map char)) => [ ]
(class-hierarchy obj)
Lists the class and interface hierarchy for the class
(class-hierarchy String) => [java.lang.String [java.lang.Object #{java.io.Serializable java.lang.Comparable java.lang.CharSequence}]]
Lists the class and interface hierarchy for the class (class-hierarchy String) => [java.lang.String [java.lang.Object #{java.io.Serializable java.lang.Comparable java.lang.CharSequence}]]
(class-info obj)
Lists class information
(class-info String) => (contains {:name "java.lang.String" :hash anything :modifiers #{:instance :class :public :final}})
Lists class information (class-info String) => (contains {:name "java.lang.String" :hash anything :modifiers #{:instance :class :public :final}})
(context-class obj)
If x is a class, return x otherwise return the class of x
(context-class String) => String
(context-class "") => String
If x is a class, return x otherwise return the class of x (context-class String) => String (context-class "") => String
(delegate obj)
Allow transparent field access and manipulation to the underlying object.
(def a "hello") (def >a (delegate a))
(mapv char (>a :value)) => [\h \e \l \l \o]
(>a :value world-array) a => "world"
Allow transparent field access and manipulation to the underlying object. (def a "hello") (def >a (delegate a)) (mapv char (>a :value)) => [\h \e \l \l \o] (>a :value world-array) a => "world"
(extract-to-ns class)
(extract-to-ns nssym class)
(extract-to-ns nssym class selectors)
extracts all class methods into its own namespace.
(map #(.sym %) (extract-to-ns 'test.string String [:private #"serial"])) => '[serialPersistentFields serialVersionUID]
extracts all class methods into its own namespace. (map #(.sym %) (extract-to-ns 'test.string String [:private #"serial"])) => '[serialPersistentFields serialVersionUID]
(extract-to-var varsym class method)
(extract-to-var varsym class method selectors)
(extract-to-var nssym varsym class method selectors)
extracts a class method into a namespace.
(extract-to-var 'hash-without clojure.lang.IPersistentMap 'without [])
(with-out-str (eval '(clojure.repl/doc hash-without))) => (str "-------------------------\n" "hara.reflect.core.extract-test/hash-without\n" "[[clojure.lang.IPersistentMap java.lang.Object]]\n" " \n" "member: clojure.lang.IPersistentMap/without\n" "type: clojure.lang.IPersistentMap\n" "modifiers: instance, method, public, abstract\n")
(eval '(hash-without {:a 1 :b 2} :a)) => {:b 2}
extracts a class method into a namespace. (extract-to-var 'hash-without clojure.lang.IPersistentMap 'without []) (with-out-str (eval '(clojure.repl/doc hash-without))) => (str "-------------------------\n" "hara.reflect.core.extract-test/hash-without\n" "[[clojure.lang.IPersistentMap java.lang.Object]]\n" " \n" "member: clojure.lang.IPersistentMap/without\n" "type: clojure.lang.IPersistentMap\n" "modifiers: instance, method, public, abstract\n") (eval '(hash-without {:a 1 :b 2} :a)) => {:b 2}
(query-class obj selectors)
queries the java view of the class declaration
(query-class String [#"^c" :name]) ;;=> ["charAt" "checkBounds" "codePointAt" "codePointBefore" ;; "codePointCount" "compareTo" "compareToIgnoreCase" ;; "concat" "contains" "contentEquals" "copyValueOf"]
queries the java view of the class declaration (query-class String [#"^c" :name]) ;;=> ["charAt" "checkBounds" "codePointAt" "codePointBefore" ;; "codePointCount" "compareTo" "compareToIgnoreCase" ;; "concat" "contains" "contentEquals" "copyValueOf"]
(query-hierarchy obj selectors)
lists what methods could be applied to a particular instance
(query-hierarchy String [:name #"^to"]) => ["toCharArray" "toLowerCase" "toString" "toUpperCase"]
lists what methods could be applied to a particular instance (query-hierarchy String [:name #"^to"]) => ["toCharArray" "toLowerCase" "toString" "toUpperCase"]
(query-instance obj selectors)
lists what methods could be applied to a particular instance
(query-instance "abc" [:name #"^to"]) => ["toCharArray" "toLowerCase" "toString" "toUpperCase"]
(query-instance String [:name #"^to"]) => (contains ["toString"])
lists what methods could be applied to a particular instance (query-instance "abc" [:name #"^to"]) => ["toCharArray" "toLowerCase" "toString" "toUpperCase"] (query-instance String [:name #"^to"]) => (contains ["toString"])
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close