std.lib.class

+primitive-lookup+

+primitive-records+

+primitives+

ancestor:all

added in 3.0

(ancestor:all cls)

returns all ancestors for a given type, itself included

(ancestor:all String) => #{java.lang.CharSequence java.lang.constant.ConstantDesc java.lang.constant.Constable java.lang.Comparable java.lang.String java.io.Serializable java.lang.Object}

ancestor:list

added in 3.0

(ancestor:list cls)(ancestor:list cls output)

Lists the direct ancestors of a class (ancestor:list clojure.lang.PersistentHashMap) => clojure.lang.PersistentHashMap clojure.lang.APersistentMap clojure.lang.AFn java.lang.Object

ancestor:tree

added in 3.0

(ancestor:tree cls)(ancestor:tree cls output)

Lists the hierarchy of bases and interfaces of a class. (ancestor:tree Class) => java.lang.Object

class:abstract?

added in 3.0

(class:abstract? class)

returns true if class is an abstract class

(class:abstract? java.util.Map) => true

(class:abstract? Class) => false

class:array-component

added in 3.0

(class:array-component cls)

returns the array element within the array

(class:array-component (type (int-array 0))) => Integer/TYPE

(class:array-component (type (into-array 1 2 3))) => java.lang.Long

class:array?

added in 3.0

(class:array? cls)

checks if a class is an array class

(class:array? (type (int-array 0))) => true

class:inherits?

added in 3.0

(class:inherits? ancestor cls)

checks if one class inherits from another

(class:inherits? clojure.lang.ILookup clojure.lang.APersistentMap) => true

class:interface?

added in 3.0

(class:interface? class)

returns true if class is an interface

(class:interface? java.util.Map) => true

(class:interface? Class) => false

class:interfaces

added in 3.0

(class:interfaces cls)

Lists all interfaces for a class

(class:interfaces clojure.lang.AFn) => #{java.lang.Runnable java.util.concurrent.Callable clojure.lang.IFn}

class:match

added in 3.0

(class:match candidates cls)

finds the best matching interface or class from a list of candidates

(class:match #{Object} Long) => Object (class:match #{String} Long) => nil (class:match #{Object Number} Long) => Number

create-lookup

added in 3.0

(create-lookup m)(create-lookup m ignore)

creates a path lookup given a record

(create-lookup {:byte {:name “byte” :size 1} :long {:name “long” :size 4}}) => {“byte” :byte :name 1 :byte :size “long” :long :name 4 :long :size}

primitive

added in 3.0

(primitive v to)

Converts primitive values across their different representations. The choices are: :raw - The string in the jdk (i.e. Z for Boolean, C for Character) :symbol - The symbol that std.object.query uses for matching (i.e. boolean, char, int) :string - The string that std.object.query uses for matching :class - The primitive class representation of the primitive :container - The containing class representation for the primitive type

primitive:array?

added in 3.0

(primitive:array? cls)

checks if class is a primitive array

(primitive:array? (type (int-array 0))) => true

(primitive:array? (type (into-array 1 2 3))) => false

primitive?

added in 3.0

(primitive? cls)

checks if a class of primitive type