   (doto (ProvisionedThroughput.)
     (.setReadCapacityUnits  (long read-units))
     (.setWriteCapacityUnits (long write-units))))
+
+(defn- set-of [pred s] (and (set? s) (every? pred s)))
+(def ^:private ^:const ba-class (Class/forName "[B"))
+(defn- ba? [x] (instance? ba-class x))
+(defn- ba-buffer [^bytes ba] (ByteBuffer/wrap ba))
+
+(defn- to-attr-value
+  "Returns an AttributeValue object for given Clojure value."
+  ;; TODO Nippy support
+  ;; TODO More efficient set-type dispatch
+  [x]
+  (cond
+   (string? x)        (doto (AttributeValue.) (.setS x))
+   (number? x)        (doto (AttributeValue.) (.setN (str x)))
+   (ba?     x)        (doto (AttributeValue.) (.setB (ba-buffer x)))
+   (set-of string? x) (doto (AttributeValue.) (.setSS x))
+   (set-of number? x) (doto (AttributeValue.) (.setNS (map str x)))
+   (set-of ba?     x) (doto (AttributeValue.) (.setBS (map ba-buffer x)))
+   (set? x)           (throw (Exception. "Set must contain values of the same type."))
+   :else              (throw (Exception. (str "Unknown value type: " (type x))))))
+
+(comment (map to-attr-value ["foo" 10 3.14 (.getBytes "foo")
+                             #{"a" "b" "c"} #{1 2 3.14} #{(.getBytes "foo")}]))
 
 ;;;; TODO Dev
 

             WriteRequest]
            com.amazonaws.ClientConfiguration
            com.amazonaws.auth.BasicAWSCredentials
            com.amazonaws.services.dynamodb.AmazonDynamoDBClient))

;;;; TODO Rotary PRs
;; * Feature/can update dynamo items (mrgordon)

      .listTables
      .getTableNames
      seq))

(defn- item-map
  "Turn a item in DynamoDB into a Clojure map."
