From ccb3a840c68baebe89620f3fa895ab30ff240061 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 17 Sep 2010 20:46:31 -0400 Subject: [PATCH] Attributed, attaches attributes to arbitrary data --- util/collection/Attributes.scala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/collection/Attributes.scala b/util/collection/Attributes.scala index 488142ad7..4037884dd 100644 --- a/util/collection/Attributes.scala +++ b/util/collection/Attributes.scala @@ -53,4 +53,13 @@ private class BasicAttributeMap(private val backing: Map[AttributeKey[_], Any]) final case class AttributeEntry[T](a: AttributeKey[T], b: T) { override def toString = a.label + ": " + b +} + +final case class Attributed[D](data: D)(val metadata: AttributeMap) +{ + def put[T](key: AttributeKey[T], value: T): Attributed[D] = Attributed(data)(metadata.put(key, value)) +} +object Attributed +{ + implicit def blank[T](data: T): Attributed[T] = Attributed(data)(AttributeMap.empty) } \ No newline at end of file