Liking cljdoc? Tell your friends :D

hara.object


class-convertclj

(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[][]"
raw docstring

class-hierarchyclj

(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}]]
raw docstring

class-infoclj

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

constructor?clj

(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
raw docstring

context-classclj

(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
raw docstring

delegateclj

(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"
raw docstring

elementclj

(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
raw docstring

element?clj

(element? x)

checker for the element type

(element? (element {})) => true

checker for the element type

(element? (element {}))
=> true
raw docstring

field?clj

(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
raw docstring

from-dataclj

(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"]
raw docstring

getclj

(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"
raw docstring

get-inclj

(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])
raw docstring

instance?clj

(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]
raw docstring

keysclj

(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])
raw docstring

map-likecljmacro

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

meta-clearclj

(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
raw docstring

meta-readclj

(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?}}})
raw docstring

meta-read-exactclj

(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
raw docstring

meta-read-exact?clj

(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
raw docstring

meta-writeclj

(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?}}})
raw docstring

meta-write-exactclj

(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
raw docstring

meta-write-exact?clj

(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
raw docstring

method?clj

(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
raw docstring

plain?clj

(plain? elem)

checks if an element is neither public or private

checks if an element is neither public or private
raw docstring

private?clj

(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[]]
raw docstring

public?clj

(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]
raw docstring

query-classclj

(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"]
raw docstring

query-hierarchyclj

(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"]
raw docstring

query-instanceclj

(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"])
raw docstring

read-all-gettersclj

(read-all-getters cls)
(read-all-getters cls {:keys [prefix template extra] :as 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]
raw docstring

read-exclj

(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
raw docstring

read-fieldsclj

(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]
raw docstring

read-gettersclj

(read-getters cls)
(read-getters cls opts)
(read-getters cls {:keys [prefix template extra] :as 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]
raw docstring

setclj

(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"
raw docstring

static?clj

(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]
raw docstring

string-likecljmacro

(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"
raw docstring

struct-accessorclj

(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?})
raw docstring

struct-fieldsclj

(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?})
raw docstring

struct-gettersclj

(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"}}
raw docstring

to-dataclj

(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"})
raw docstring

to-elementclj

(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]
raw docstring

to-mapclj

(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"})
raw docstring

unextendclj

(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]]]
raw docstring

vector-likecljmacro

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

write-all-settersclj

(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]
raw docstring

write-exclj

(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
raw docstring

write-fieldsclj

(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]
raw docstring

write-settersclj

(write-setters cls)
(write-setters cls opts)
(write-setters
  cls
  {:keys [prefix template create]
   :or {prefix "set" template +write-template+ create create-write-method}}
  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]
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close