mirror of https://github.com/sbt/sbt.git
Attributed, attaches attributes to arbitrary data
This commit is contained in:
parent
b033bc889d
commit
ccb3a840c6
|
|
@ -53,4 +53,13 @@ private class BasicAttributeMap(private val backing: Map[AttributeKey[_], Any])
|
||||||
final case class AttributeEntry[T](a: AttributeKey[T], b: T)
|
final case class AttributeEntry[T](a: AttributeKey[T], b: T)
|
||||||
{
|
{
|
||||||
override def toString = a.label + ": " + b
|
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)
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue