instance? recognizes common host interfaces
(instance? clojure.lang.Named :a), java.lang.CharSequence/Number, java.util.Map/Set/List/Collection, clojure.lang.Associative now report true for jolt's value model, matching the JVM (a Map is not a Collection; a List excludes sets/maps). Libraries branch on these — data.json's default-write-key-fn keys on clojure.lang.Named, so map keys serialized with the leading colon before this.
This commit is contained in:
parent
21895cb932
commit
c6b8f31608
2 changed files with 28 additions and 0 deletions
|
|
@ -535,6 +535,24 @@
|
|||
((string=? iface "IFn")
|
||||
(or (procedure? val) (keyword? val) (symbol-t? val)
|
||||
(pmap? val) (pset? val) (pvec? val)))
|
||||
;; host-class interfaces libraries branch on (data.json, etc.).
|
||||
;; Matched by last segment, so java.util.Map and Map both hit.
|
||||
((string=? iface "Named") (or (keyword? val) (symbol-t? val)))
|
||||
((string=? iface "CharSequence") (string? val))
|
||||
((string=? iface "Number") (number? val))
|
||||
((string=? iface "Map") (or (pmap? val) (htable-sorted-map? val)))
|
||||
((string=? iface "Set") (or (pset? val) (htable-sorted-set? val)))
|
||||
;; a Java List is a vector or a seq/list — not a set or map.
|
||||
((string=? iface "List")
|
||||
(or (and (pvec? val) (not (jolt-map-entry? val)))
|
||||
(cseq? val) (empty-list-t? val) (jolt-lazyseq? val)))
|
||||
;; a Java Collection is any of those plus a set — but NOT a map.
|
||||
((string=? iface "Collection")
|
||||
(or (pvec? val) (pset? val) (cseq? val) (empty-list-t? val)
|
||||
(jolt-lazyseq? val) (htable-sorted-set? val)))
|
||||
((string=? iface "Associative")
|
||||
(or (pmap? val) (htable-sorted-map? val)
|
||||
(and (pvec? val) (not (jolt-map-entry? val)))))
|
||||
(else 'none))))
|
||||
(if (eq? hit 'none) 'pass (if hit #t #f))))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue