Created
January 26, 2013 19:46
-
-
Save alextp/4644129 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StringMapCubbie[T](val m: mutable.Map[String,T]) extends Cubbie { | |
setMap(new mutable.Map[String, Any] { | |
override def update(key: String, value: Any): Unit = { | |
value match { | |
case v: T => m(key) = v | |
case _ => throw new InvalidClassException(value.getClass.getName + " is not of the proper type.") | |
} | |
} | |
def += (kv: (String, Any)): this.type = { update(kv._1, kv._2); this } | |
def -= (key: String): this.type = sys.error("Can't remove slots from cubbie map!") | |
def get(key: String): Option[Any] = if (m.contains(key)) Some(m(key)) else None | |
def iterator: Iterator[(String, Any)] = m.iterator | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment