reflect

clojure.reflect

  • (reflect obj & options)
Alpha - subject to change.
Reflect on the type of obj (or obj itself if obj is a class).
Return value and options are the same as for type-reflect.

1 Example top

  • user=> (use 'clojure.reflect 'clojure.pprint)
    nil
    user=> (def r (reflect *in*))
    #'user/r
    user=> (count (:members r))
    9
    user=> (pprint (map class (:members r)))
    (clojure.reflect.Constructor
     clojure.reflect.Method
     clojure.reflect.Field
     clojure.reflect.Field
     clojure.reflect.Method
     clojure.reflect.Method
     clojure.reflect.Method
     clojure.reflect.Method
     clojure.reflect.Field)
    nil
    user=> (pprint r)
    {:bases #{java.io.PushbackReader},
     :flags #{:public},
     :members
     #{{:name clojure.lang.LineNumberingPushbackReader,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :parameter-types [java.io.Reader],
        :exception-types [],
        :flags #{:public}}
       {:name read,
        :return-type int,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :parameter-types [],
        :exception-types [java.io.IOException],
        :flags #{:public}}
       {:name _atLineStart,
        :type boolean,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :flags #{:private}}
       {:name newline,
        :type int,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :flags #{:private :static :final}}
       {:name unread,
        :return-type void,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :parameter-types [int],
        :exception-types [java.io.IOException],
        :flags #{:public}}
       {:name readLine,
        :return-type java.lang.String,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :parameter-types [],
        :exception-types [java.io.IOException],
        :flags #{:public}}
       {:name atLineStart,
        :return-type boolean,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :parameter-types [],
        :exception-types [],
        :flags #{:public}}
       {:name getLineNumber,
        :return-type int,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :parameter-types [],
        :exception-types [],
        :flags #{:public}}
       {:name _prev,
        :type boolean,
        :declaring-class clojure.lang.LineNumberingPushbackReader,
        :flags #{:private}}}}
    nil
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/reflect.clj:115 top

(defn reflect
  "Alpha - subject to change.
   Reflect on the type of obj (or obj itself if obj is a class).
   Return value and options are the same as for type-reflect. "
  {:added "1.3"}
  [obj & options]
  (apply type-reflect (if (class? obj) obj (class obj)) options))
Vars in clojure.reflect/reflect:
Used in 0 other vars

Comments top

No comments for reflect. Log in to add a comment.