Meikel  Brandmeyer avatar Meikel Brandmeyer committed accb3b6

Adapted to newest new branch snapshot

Comments (0)

Files changed (1)

src/main/clojure/de/kotka/lazymap.clj

 
 (defn create-lazy-map-entry
   [k v]
-  (reify this [ILazyMapEntry]
+  (reify [ILazyMapEntry]
     ; ILazyMapEntry
-    (.getRawValue
-      []
-      v)
+    (getRawValue [this] v)
     ; IMapEntry
-    (.key
-      []
-      (.getKey this))
-    (.getKey
-      []
-      k)
-    (.val
-      []
-      (.getValue this))
-    (.getValue
-      []
-      (force v))
+    (key         [this] (.getKey this))
+    (getKey      [this] k)
+    (val         [this] (.getValue this))
+    (getValue    [this] (force v))
     ; Object
-    (.toString
-      []
-      (str \[ (.getKey this) \space (.getValue this) \]))))
+    (toString    [this] (str \[ (.getKey this) \space (.getValue this) \]))))
 
 (defmethod print-method ILazyMapEntry
   [#^ILazyMapEntry this #^java.io.Writer writer]
   ([inner-seq]
    (create-lazy-map-seq inner-seq nil))
   ([inner-seq metadata]
-   (reify this [ISeq IObj]
+   (reify [ISeq IObj]
      ; ISeq
-     (.first
-       []
+     (first
+       [this]
        (let [first-val (first inner-seq)]
          (create-lazy-map-entry (key first-val) (val first-val))))
-     (.next
-       []
+     (next
+       [this]
        (when-let [inner-rest (next inner-seq)]
          (create-lazy-map-seq inner-rest metadata)))
-     (.more
-       []
-       (lazy-seq
-         (.next this)))
-     (.cons
-       [o]
-       (concat [o] this))
+     (more  [this]   (lazy-seq (.next this)))
+     (cons  [this o] (cons o this))
      ; IPersistentCollection
-     (.count
-       []
-       (count inner-seq))
-     (.empty
-       []
-       ())
-     (.seq
-       []
-       this)
+     (count [this]   (count inner-seq))
+     (empty [this]   ())
+     (seq   [this]   this)
      ; IObj
-     (.withMeta
-       [new-metadata]
-       (create-lazy-map-seq inner-seq new-metadata))
+     (withMeta [this new-metadata] (create-lazy-map-seq inner-seq new-metadata))
      ;IMeta
-     (.meta
-       []
-       metadata))))
+     (meta  [this]   metadata))))
 
 (defn create-lazy-map
   ([base]
    (create-lazy-map base nil))
   ([base metadata]
-   (reify this [ILazyMap IFn IObj]
+   (reify [ILazyMap IFn IObj]
      ; ILazyMap
-     (.lazyAssoc
-       [k v]
-       (create-lazy-map (assoc base k v) metadata))
+     (lazyAssoc [this k v] (create-lazy-map (assoc base k v) metadata))
      ; IPersistentMap
-     (.assoc
-       [k v]
-       (create-lazy-map (assoc base k (delay v)) metadata))
-     (.assocEx
-       [k v]
+     (assoc     [this k v] (create-lazy-map (assoc base k (delay v)) metadata))
+     (assocEx
+       [this k v]
        (when (.containsKey base k)
          (throw (Exception. (str "Key already present in map: " k))))
        (.assoc this k v))
-     (.without
-       [k]
-       (create-lazy-map (dissoc base k) metadata))
+     (without     [this k] (create-lazy-map (dissoc base k) metadata))
      ; Associative
-     (.containsKey
-       [k]
-       (contains? base k))
-     (.entryAt
-       [k]
-       (create-lazy-map-entry k (base k)))
+     (containsKey [this k] (contains? base k))
+     (entryAt     [this k] (create-lazy-map-entry k (base k)))
      ; IPersistentCollection
-     (.count
-       []
-       (count base))
-     (.cons
-       [o]
+     (count       [this]   (count base))
+     (cons
+       [this o]
        (condp instance? o
          ILazyMapEntry     (let [#^ILazyMapEntry o o]
                              (let [k (.getKey o)
                              (throw (IllegalArgumentException.
                                       "Vector arg to map conj must be a pair")))
          (reduce #(.cons #^ILazyMap %1 %2) this o)))
-     (.empty
-       []
-       (create-lazy-map (empty base) nil))
+     (empty [this]   (create-lazy-map (empty base) nil))
      ; ILookup
-     (.valAt
-       [k]
-       (.valAt this k nil))
-     (.valAt
-       [k not-found]
+     (valAt [this k] (.valAt this k nil))
+     (valAt
+       [this k not-found]
        (if (contains? base k)
          (-> base (get k) force)
          not-found))
      ; IFn
-     (.invoke
-       [k]
-       (.valAt this k nil))
-     (.invoke
-       [k not-found]
-       (.valAt this k not-found))
-     (.applyTo
-       [args]
+     (invoke [this k]           (.valAt this k nil))
+     (invoke [this k not-found] (.valAt this k not-found))
+     (applyTo
+       [this args]
        (let [[k v & rest-args :as args] (seq args)]
          (when (or (not args) rest-args)
            (throw (Exception. "lazy map must be called with one or two arguments")))
          (.valAt this k v)))
      ; Seqable
-     (.seq
-       []
+     (seq
+       [this]
        (when-let [inner-seq (seq base)]
          (create-lazy-map-seq inner-seq)))
      ; IObj
-     (.withMeta
-       [new-metadata]
-       (create-lazy-map base new-metadata))
+     (withMeta [this new-metadata] (create-lazy-map base new-metadata))
      ; IMeta
-     (.meta
-       []
-       metadata)
+     (meta     [this] metadata)
      ; Iterable
-     (.iterator
-       []
-       (-> this .seq SeqIterator.)))))
+     (iterator [this] (-> this .seq SeqIterator.)))))
 
 (defn- quote-values
   [kvs]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.