std.object.framework

invoke-intern-object

added in 3.0

(invoke-intern-object name config body)(invoke-intern-object _ name {:keys [type extend tag read write display], :as config} body)

creates an invoke form for an object

(framework/invoke-intern-object ’-cl-context- {:type org.eclipse.jgit.lib.PersonIdent :tag “person” :exclude :time-zone} ’([] nil))

map-like

macro

added in 3.0

(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))})

string-like

macro

added in 3.0

(string-like & {:as classes})

creates an accessibility layer for string-like objects

(framework/string-like java.io.File {:tag “path” :read (fn ^java.io.File 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”

unextend

added in 3.0

(unextend cls)

unextend a given class from the object framework

(framework/unextend org.eclipse.jgit.lib.PersonIdent) ;;=>

vector-like

macro

added in 3.0

(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))})