Skip to content

Commit

Permalink
toStrings for some concurrent restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Sep 4, 2012
1 parent d6a45e8 commit 52b4db3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main/Tags.scala
Expand Up @@ -32,10 +32,12 @@ object Tags
private[this] final class Single(tag: Tag, max: Int) extends Rule {
checkMax(max)
def apply(m: TagMap) = getInt(m, tag) <= max
override def toString = "Limit " + tag.name + " to " + max
}
private[this] final class Sum(tags: Seq[Tag], max: Int) extends Rule {
checkMax(max)
def apply(m: TagMap) = (0 /: tags)((sum, t) => sum + getInt(m, t)) <= max
def apply(m: TagMap) = (0 /: tags)((sum, t) => sum + getInt(m, t)) <= max
override def toString = tags.mkString("Limit sum of ", ", ", " to " + max)
}
private[this] def checkMax(max: Int): Unit = assert(max >= 1, "Limit must be at least 1.")

Expand Down

0 comments on commit 52b4db3

Please sign in to comment.