TypedMap

play.api.libs.typedmap.TypedMap
See theTypedMap companion object
trait TypedMap

A TypedMap is an immutable map containing typed values. Each entry is associated with a TypedKey that can be used to look up the value. A TypedKey also defines the type of the value, e.g. a TypedKey[String] would be associated with a String value.

Instances of this class are created with the TypedMap.empty method.

The elements inside TypedMaps cannot be enumerated. This is a decision designed to enforce modularity. It's not possible to accidentally or intentionally access a value in a TypedMap without holding the corresponding TypedKey.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def apply[A](key: TypedKey[A]): A

Get a value from the map, throwing an exception if it is not present.

Get a value from the map, throwing an exception if it is not present.

Type parameters

A

The type of value to retrieve.

Value parameters

key

The key for the value to retrieve.

Attributes

Returns

The value, if it is present in the map.

Throws
scala.NoSuchElementException

If the value isn't present in the map.

def contains(key: TypedKey[_]): Boolean

Check if the map contains a value with the given key.

Check if the map contains a value with the given key.

Value parameters

key

The key to check for.

Attributes

Returns

True if the value is present, false otherwise.

def get[A](key: TypedKey[A]): Option[A]

Get a value from the map, returning None if it is not present.

Get a value from the map, returning None if it is not present.

Type parameters

A

The type of value to retrieve.

Value parameters

key

The key for the value to retrieve.

Attributes

Returns

Some value, if it is present in the map, otherwise None.

def removed(e1: TypedKey[_]): TypedMap

Removes a key from the map, returning a new instance of the map.

Removes a key from the map, returning a new instance of the map.

Value parameters

e1

The key to remove.

Attributes

Returns

A new instance of the map with the entry removed.

def removed(e1: TypedKey[_], e2: TypedKey[_]): TypedMap

Removes two keys from the map, returning a new instance of the map.

Removes two keys from the map, returning a new instance of the map.

Value parameters

e1

The first key to remove.

e2

The second key to remove.

Attributes

Returns

A new instance of the map with the entries removed.

def removed(e1: TypedKey[_], e2: TypedKey[_], e3: TypedKey[_]): TypedMap

Removes three keys from the map, returning a new instance of the map.

Removes three keys from the map, returning a new instance of the map.

Value parameters

e1

The first key to remove.

e2

The second key to remove.

e3

The third key to remove.

Attributes

Returns

A new instance of the map with the entries removed.

def removed(keys: TypedKey[_]*): TypedMap

Removes keys from the map, returning a new instance of the map.

Removes keys from the map, returning a new instance of the map.

Value parameters

keys

The keys to remove.

Attributes

Returns

A new instance of the map with the entries removed.

def updated[A](key: TypedKey[A], value: A): TypedMap

Update the map with the given key and value, returning a new instance of the map.

Update the map with the given key and value, returning a new instance of the map.

Type parameters

A

The type of value.

Value parameters

key

The key to set.

value

The value to use.

Attributes

Returns

A new instance of the map with the new entry added.

def updated(e1: TypedEntry[_]): TypedMap

Update the map with one entry, returning a new instance of the map.

Update the map with one entry, returning a new instance of the map.

Value parameters

e1

The new entry to add to the map.

Attributes

Returns

A new instance of the map with the new entry added.

def updated(e1: TypedEntry[_], e2: TypedEntry[_]): TypedMap

Update the map with two entries, returning a new instance of the map.

Update the map with two entries, returning a new instance of the map.

Value parameters

e1

The first new entry to add to the map.

e2

The second new entry to add to the map.

Attributes

Returns

A new instance of the map with the new entries added.

def updated(e1: TypedEntry[_], e2: TypedEntry[_], e3: TypedEntry[_]): TypedMap

Update the map with three entries, returning a new instance of the map.

Update the map with three entries, returning a new instance of the map.

Value parameters

e1

The first new entry to add to the map.

e2

The second new entry to add to the map.

e3

The third new entry to add to the map.

Attributes

Returns

A new instance of the map with the new entries added.

def updated(entries: TypedEntry[_]*): TypedMap

Update the map with several entries, returning a new instance of the map.

Update the map with several entries, returning a new instance of the map.

Value parameters

entries

The new entries to add to the map.

Attributes

Returns

A new instance of the map with the new entries added.

Concrete methods

def asJava: TypedMap

Attributes

Returns

The Java version for this map.

Deprecated methods

def +(entries: TypedEntry[_]*): TypedMap

Update the map with several entries, returning a new instance of the map.

Update the map with several entries, returning a new instance of the map.

Value parameters

entries

The new entries to add to the map.

Attributes

Returns

A new instance of the map with the new entries added.

Deprecated
[Since version 2.9.0] Use `updated` instead.
def -(keys: TypedKey[_]*): TypedMap

Removes keys from the map, returning a new instance of the map.

Removes keys from the map, returning a new instance of the map.

Value parameters

keys

The keys to remove.

Attributes

Returns

A new instance of the map with the entries removed.

Deprecated
[Since version 2.9.0] Use `removed` instead.