(class-convert v)
(class-convert v to)
Converts a class to its representation.
(class-convert "byte") => Byte/TYPE
(class-convert 'byte :string) => "byte"
(class-convert (Class/forName "[[B") :string) => "byte[][]"
Converts a class to its representation. (class-convert "byte") => Byte/TYPE (class-convert 'byte :string) => "byte" (class-convert (Class/forName "[[B") :string) => "byte[][]"
(class-hierarchy obj)
Lists the class and interface hierarchy for the class
(element/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 (element/class-hierarchy String) => [java.lang.String [java.lang.Object #{java.io.Serializable java.lang.Comparable java.lang.CharSequence}]]
(class-info obj)
Lists class information
(element/class-info String) => (contains {:name "java.lang.String" :hash anything :modifiers #{:instance :class :public :final}})
Lists class information (element/class-info String) => (contains {:name "java.lang.String" :hash anything :modifiers #{:instance :class :public :final}})
(constructor? elem)
checks if if an element is a constructor
(-> (.getConstructors String) (first) (element/to-element) (element/constructor?)) => true
checks if if an element is a constructor (-> (.getConstructors String) (first) (element/to-element) (element/constructor?)) => true
(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-)) (def -world-array- (.getBytes "world"))
(mapv char (-*a- :value)) => [\h \e \l \l \o]
(-*a- :value -world-array-) (String. (-*a- :value)) => "world" -a- => "world"
Allow transparent field access and manipulation to the underlying object. (def -a- "hello") (def -*a- (delegate -a-)) (def -world-array- (.getBytes "world")) (mapv char (-*a- :value)) => [\h \e \l \l \o] (-*a- :value -world-array-) (String. (-*a- :value)) => "world" -a- => "world"
(element body)
creates a element from a map
(element {}) => hara.object.element.common.Element
creates a element from a map (element {}) => hara.object.element.common.Element
(element? x)
checker for the element type
(element? (element {})) => true
checker for the element type (element? (element {})) => true
(field? elem)
checks if an element is a field
(-> (.getFields String) (first) (element/to-element) (element/field?)) => true
checks if an element is a field (-> (.getFields String) (first) (element/to-element) (element/field?)) => true
(from-data arg cls)
creates the object from data
(-> (write/from-data ["hello"] (Class/forName "[Ljava.lang.String;")) seq) => ["hello"]
creates the object from data (-> (write/from-data ["hello"] (Class/forName "[Ljava.lang.String;")) seq) => ["hello"]
(get obj k)
accessor with either keyword or array lookup
(access/get (test.Cat. "spike") :name) => "spike"
accessor with either keyword or array lookup (access/get (test.Cat. "spike") :name) => "spike"
(get-in obj ks)
accesses the nested object using specifiedb path
(access/get-in (test.Cat. "spike") [:name])
accesses the nested object using specifiedb path (access/get-in (test.Cat. "spike") [:name])
(instance? elem)
checks if an element is non static
(->> (.getMethods String) (map element/to-element) (filter element/instance?) first) ;;#elem[equals :: (java.lang.String, java.lang.Object) -> boolean]
checks if an element is non static (->> (.getMethods String) (map element/to-element) (filter element/instance?) first) ;;#elem[equals :: (java.lang.String, java.lang.Object) -> boolean]
(keys obj)
gets all keys of an object
(access/keys (test.Cat. "spike")) => (contains [:name])
gets all keys of an object (access/keys (test.Cat. "spike")) => (contains [:name])
(map-like & {:as classes})
creates an accessibility layer for map-like objects
(framework/map-like org.eclipse.jgit.revwalk.RevCommit {:tag "commit" :include [:commit-time :name :author-ident :full-message]})
(framework/map-like org.eclipse.jgit.lib.PersonIdent {:tag "person" :exclude [:time-zone]})
(framework/map-like org.eclipse.jgit.api.Status {:tag "status" :display (fn [m] (reduce-kv (fn [out k v] (if (and (or (instance? java.util.Collection v) (instance? java.util.Map v)) (empty? v)) out (assoc out k v))) {} m))})
creates an accessibility layer for map-like objects (framework/map-like org.eclipse.jgit.revwalk.RevCommit {:tag "commit" :include [:commit-time :name :author-ident :full-message]}) (framework/map-like org.eclipse.jgit.lib.PersonIdent {:tag "person" :exclude [:time-zone]}) (framework/map-like org.eclipse.jgit.api.Status {:tag "status" :display (fn [m] (reduce-kv (fn [out k v] (if (and (or (instance? java.util.Collection v) (instance? java.util.Map v)) (empty? v)) out (assoc out k v))) {} m))})
(meta-clear class)
clears all meta-read and meta-write definitions for a class
clears all meta-read and meta-write definitions for a class
(meta-read cls)
access read attributes
(read/meta-read Pet) => (contains-in {:class test.Pet :methods {:name {:fn fn?} :species {:fn fn?}}})
access read attributes (read/meta-read Pet) => (contains-in {:class test.Pet :methods {:name {:fn fn?} :species {:fn fn?}}})
(meta-read-exact cls)
access read attributes for the exact class
(read/meta-read-exact Object) => nil
access read attributes for the exact class (read/meta-read-exact Object) => nil
(meta-read-exact? cls)
checks if read attributes are avaliable
(read/meta-read-exact? Object) => false
checks if read attributes are avaliable (read/meta-read-exact? Object) => false
(meta-write cls)
access read-attributes with caching
(write/meta-write DogBuilder) => (contains-in {:class test.DogBuilder :empty fn?, :methods {:name {:type java.lang.String, :fn fn?}}})
access read-attributes with caching (write/meta-write DogBuilder) => (contains-in {:class test.DogBuilder :empty fn?, :methods {:name {:type java.lang.String, :fn fn?}}})
(meta-write-exact cls)
access write attributes for the exact class
(write/meta-write-exact Object) => nil
access write attributes for the exact class (write/meta-write-exact Object) => nil
(meta-write-exact? cls)
checks if write attributes are avaliable
(write/meta-write-exact? Object) => false
checks if write attributes are avaliable (write/meta-write-exact? Object) => false
(method? elem)
checks if an element is a method
(-> (.getMethods String) (first) (element/to-element) (element/method?)) => true
checks if an element is a method (-> (.getMethods String) (first) (element/to-element) (element/method?)) => true
(plain? elem)
checks if an element is neither public or private
checks if an element is neither public or private
(private? elem)
checks if an element is private
(->> (.getDeclaredFields String) (map element/to-element) (filter element/private?) first) ;;#elem[value :: (java.lang.String) | byte[]]
checks if an element is private (->> (.getDeclaredFields String) (map element/to-element) (filter element/private?) first) ;;#elem[value :: (java.lang.String) | byte[]]
(public? elem)
checks if an element is public
(->> (.getMethods String) (map element/to-element) (filter element/public?) first) ;;#elem[equals :: (java.lang.String, java.lang.Object) -> boolean]
checks if an element is public (->> (.getMethods String) (map element/to-element) (filter element/public?) first) ;;#elem[equals :: (java.lang.String, java.lang.Object) -> boolean]
(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 class 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 class methods could be applied to a particular instance (query-instance "abc" [:name #"^to"]) => ["toCharArray" "toLowerCase" "toString" "toUpperCase"] (query-instance String [:name #"^to"]) => (contains ["toString"])
(read-all-getters cls)
(read-all-getters cls opts)
returns fields of an object and base classes (-> (read/read-all-getters Dog) keys) => [:class :name :species]
returns fields of an object and base classes (-> (read/read-all-getters Dog) keys) => [:class :name :species]
(read-ex k)
creates a getter method that throws an an exception
((read/read-ex :hello) nil) => throws
creates a getter method that throws an an exception ((read/read-ex :hello) nil) => throws
(read-fields cls)
(read-fields cls query-fn)
fields of an object from reflection (-> (read/read-fields Dog) keys) => [:name :species]
fields of an object from reflection (-> (read/read-fields Dog) keys) => [:name :species]
(read-getters cls)
(read-getters cls opts)
(read-getters cls opts query-fn)
returns fields of an object through getter methods (-> (read/read-getters Dog) keys) => [:name :species]
returns fields of an object through getter methods (-> (read/read-getters Dog) keys) => [:name :species]
(read-getters-form cls)
(read-getters-form cls opts)
(read-getters-form cls {:keys [prefix template extra] :as opts} query-fn)
creates the form for read-getters
(read/read-getters-form Dog) => '{:name {:type java.lang.String, :fn (clojure.core/fn getName [obj] (. obj (getName)))}, :species {:type java.lang.String, :fn (clojure.core/fn getSpecies [obj] (. obj (getSpecies)))}}
creates the form for read-getters (read/read-getters-form Dog) => '{:name {:type java.lang.String, :fn (clojure.core/fn getName [obj] (. obj (getName)))}, :species {:type java.lang.String, :fn (clojure.core/fn getSpecies [obj] (. obj (getSpecies)))}}
(set obj m)
(set obj k v)
sets the fields of an object with a map
(-> (doto (test.Cat. "spike") (access/set {:name "fluffy"})) (access/get :name)) => "fluffy"
sets the fields of an object with a map (-> (doto (test.Cat. "spike") (access/set {:name "fluffy"})) (access/get :name)) => "fluffy"
(static? elem)
checks if an element is a static one
(->> (.getMethods String) (map element/to-element) (filter element/static?) first) ;;#elem[valueOf :: (int) -> java.lang.String]
checks if an element is a static one (->> (.getMethods String) (map element/to-element) (filter element/static?) first) ;;#elem[valueOf :: (int) -> java.lang.String]
(string-like & {:as classes})
creates an accessibility layer for string-like objects
(framework/string-like java.io.File {:tag "path" :read (fn [f] (.getPath f)) :write (fn [^String path] (java.io.File. path))})
(object/to-data (java.io.File. "/home")) => "/home"
(object/from-data "/home" java.io.File) => java.io.File
;; Enums are automatically string-like
(object/to-data java.lang.Thread$State/NEW) => "NEW"
creates an accessibility layer for string-like objects (framework/string-like java.io.File {:tag "path" :read (fn [f] (.getPath f)) :write (fn [^String path] (java.io.File. path))}) (object/to-data (java.io.File. "/home")) => "/home" (object/from-data "/home" java.io.File) => java.io.File ;; Enums are automatically string-like (object/to-data java.lang.Thread$State/NEW) => "NEW"
(struct-accessor spec)
(struct-accessor spec access)
creates an accessor function
((struct-accessor {:value [:data] :msg [:detail-message :value]} :field) (ex-info "hello" {:a 1})) => (contains {:value {:a 1}, :msg bytes?})
creates an accessor function ((struct-accessor {:value [:data] :msg [:detail-message :value]} :field) (ex-info "hello" {:a 1})) => (contains {:value {:a 1}, :msg bytes?})
(struct-fields spec obj)
creates a struct given an object and a field map
(struct-fields {:depth []} (ex-info "hello" {:a 1})) => (contains {:depth number?})
(struct-fields {:msg [:detail-message :value]} (ex-info "hello" {:a 1})) => (contains {:msg bytes?})
creates a struct given an object and a field map (struct-fields {:depth []} (ex-info "hello" {:a 1})) => (contains {:depth number?}) (struct-fields {:msg [:detail-message :value]} (ex-info "hello" {:a 1})) => (contains {:msg bytes?})
(struct-getters spec obj)
creates a struct given an object and a getter map
(struct-getters {:value [:data] :message [] :class {:name []}} (ex-info "hello" {:a 1})) => {:value {:a 1}, :message "hello", :class {:name "clojure.lang.ExceptionInfo"}}
creates a struct given an object and a getter map (struct-getters {:value [:data] :message [] :class {:name []}} (ex-info "hello" {:a 1})) => {:value {:a 1}, :message "hello", :class {:name "clojure.lang.ExceptionInfo"}}
(to-data obj)
creates the object from a string or map
(read/to-data "hello") => "hello"
(read/to-data (write/from-map {:name "hello" :species "dog"} Pet)) => (contains {:name "hello"})
creates the object from a string or map (read/to-data "hello") => "hello" (read/to-data (write/from-map {:name "hello" :species "dog"} Pet)) => (contains {:name "hello"})
(to-element obj)
converts a java.reflect
object to a hara.object.element
one
(element/to-element (first (.getMethods String))) ;; #elem[equals :: (java.lang.String, java.lang.Object) -> boolean]
converts a `java.reflect` object to a `hara.object.element` one (element/to-element (first (.getMethods String))) ;; #elem[equals :: (java.lang.String, java.lang.Object) -> boolean]
(to-map obj)
creates a map from an object
(read/to-map (Cat. "spike")) => (contains {:name "spike"})
creates a map from an object (read/to-map (Cat. "spike")) => (contains {:name "spike"})
(unextend cls)
unextend a given class from the object framework
(framework/unextend org.eclipse.jgit.lib.PersonIdent) ;;=> [[#multifn[-meta-read 0x4ead3109] nil #multifn[print-method 0xcd219d4]]]
unextend a given class from the object framework (framework/unextend org.eclipse.jgit.lib.PersonIdent) ;;=> [[#multifn[-meta-read 0x4ead3109] nil #multifn[print-method 0xcd219d4]]]
(vector-like & {:as classes})
creates an accessibility layer for vector-like objects
(framework/vector-like org.eclipse.jgit.revwalk.RevWalk {:tag "commits" :read (fn [^org.eclipse.jgit.revwalk.RevWalk walk] (->> walk (.iterator) object/to-data))})
creates an accessibility layer for vector-like objects (framework/vector-like org.eclipse.jgit.revwalk.RevWalk {:tag "commits" :read (fn [^org.eclipse.jgit.revwalk.RevWalk walk] (->> walk (.iterator) object/to-data))})
(write-all-setters cls)
(write-all-setters cls opts)
write all setters of an object and base classes
(write/write-all-setters Dog) => {}
(keys (write/write-all-setters DogBuilder)) => [:name]
write all setters of an object and base classes (write/write-all-setters Dog) => {} (keys (write/write-all-setters DogBuilder)) => [:name]
(write-ex k)
writes a getter method that throws an an exception
((write/write-ex :hello) nil nil) => throws
writes a getter method that throws an an exception ((write/write-ex :hello) nil nil) => throws
(write-fields cls)
(write-fields cls query-fn)
write fields of an object from reflection
(-> (write/write-fields Dog) keys) => [:name :species]
write fields of an object from reflection (-> (write/write-fields Dog) keys) => [:name :species]
(write-setters cls)
(write-setters cls opts)
(write-setters cls opts query-fn)
write fields of an object through setter methods
(write/write-setters Dog) => {}
(keys (write/write-setters DogBuilder)) => [:name]
write fields of an object through setter methods (write/write-setters Dog) => {} (keys (write/write-setters DogBuilder)) => [:name]
(write-setters-form cls)
(write-setters-form cls opts)
(write-setters-form
cls
{:keys [prefix template create select]
:or {prefix "set" template +write-template+ create create-write-method-form}}
query-fn)
constructs forms for a given object
(write/write-setters-form DogBuilder) => '{:name {:type java.lang.String, :fn (clojure.core/fn setName [obj val] (clojure.core/or (. obj (setName val)) obj))}}
constructs forms for a given object (write/write-setters-form DogBuilder) => '{:name {:type java.lang.String, :fn (clojure.core/fn setName [obj val] (clojure.core/or (. obj (setName val)) obj))}}
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close