from-data ^
creates the object from data
(-> (write/from-data ["hello"] (Class/forName "[Ljava.lang.String;"))
seq)
=> ["hello"]
get ^
accessor with either keyword or array lookup
(access/get (test.Cat. "spike") :name)
=> "spike"
get-in ^
accesses the nested object using specifiedb path
(access/get-in (test.Cat. "spike") [:name])
keys ^
gets all keys of an object
(access/keys (test.Cat. "spike"))
=> (contains [:name])
map-like ^
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-read ^
access read-attributes with caching
(read/meta-read Pet)
=> (contains-in {:class test.Pet
:methods {:name fn?
:species fn?}})
meta-write ^
access read-attributes with caching
(write/meta-write DogBuilder)
=> (contains {:class test.DogBuilder
:empty fn?,
:methods (contains
{:name
(contains {:type java.lang.String, :fn fn?})})})
read-all-getters ^
returns fields of an object and base classes
(-> (read/read-all-getters Dog)
keys)
=> [:class :name :species]
read-fields ^
fields of an object from reflection
(-> (read/read-fields Dog)
keys)
=> [:name :species]
read-getters ^
returns fields of an object through getter methods
(-> (read/read-getters Dog)
keys)
=> [:name :species]
set ^
sets the fields of an object with a map
(-> (doto (test.Cat. "spike")
(access/set {:name "fluffy"}))
(access/get :name))
=> "fluffy"
string-like ^
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 ^
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 ^
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 ^
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 ^
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-map ^
creates a map from an object
(read/to-map (Cat. "spike"))
=> (contains {:name "spike"})
unextend ^
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 ^
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 ^
write all setters of an object and base classes
(write/write-all-setters Dog)
=> {}
(keys (write/write-all-setters DogBuilder))
=> [:name]
write-fields ^
write fields of an object from reflection
(-> (write/write-fields Dog)
keys)
=> [:name :species]
write-setters ^
write fields of an object through setter methods
(write/write-setters Dog)
=> {}
(keys (write/write-setters DogBuilder))
=> [:name]