# DynamicDataMap

Artifact: [androidx.wear.protolayout:protolayout-expression](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/expression/DynamicDataMap.kt+class:androidx.wear.protolayout.expression.DynamicDataMap) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

*** ** * ** ***


```
public class DynamicDataMap
```

<br />

Known direct subclasses [MutableDynamicDataMap](https://developer.android.com/reference/androidx/wear/protolayout/expression/MutableDynamicDataMap)

|---|---|
| `https://developer.android.com/reference/androidx/wear/protolayout/expression/MutableDynamicDataMap` | A mutable heterogeneous map of `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType` keys to their corresponding values. |

*** ** * ** ***

A heterogeneous map of `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType` keys to their corresponding values. This (and `https://developer.android.com/reference/androidx/wear/protolayout/expression/MutableDynamicDataMap`) act like `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html` (and `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html`), but with type safety for key and value pairs.

## Summary

| ### Public methods |
|---|---|
| `final boolean` | `<T extends https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType> https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull T> key )` Returns true if this map contains the specified `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey)` and it is associated with the specified type `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final boolean` | `<T extends https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType> https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey,java.lang.Class)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull T> key, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type )` Returns true if this map contains the specified `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey,java.lang.Class)` and it is associated with the specified `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey,java.lang.Class)`. |
| `boolean` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final https://developer.android.com/reference/java/lang/Boolean.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicBool> key)` Gets the boolean value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final https://developer.android.com/reference/android/graphics/Color.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicColor> key)` Gets the color value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final https://developer.android.com/reference/java/time/Duration.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicDuration> key)` Gets the `https://developer.android.com/reference/java/time/Duration.html` value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final https://developer.android.com/reference/java/lang/Float.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicFloat> key)` Gets the float value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final https://developer.android.com/reference/java/time/Instant.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicInstant> key)` Gets the `https://developer.android.com/reference/java/time/Instant.html` value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final https://developer.android.com/reference/java/lang/Integer.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicInt32> key)` Gets the integer value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString> key)` Gets the string value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.Entry.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataBuilders.DynamicDataValue<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType>>>` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#getEntries()()` Returns a read-only `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of all key/value pairs in this map. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType>>` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#getKeys()()` Returns a read-only `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of all keys in this map. |
| `final int` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#getSize()()` Returns the number of key/value pairs in the map. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Collection.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataBuilders.DynamicDataValue<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType>>` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#getValues()()` Returns a read-only `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html` of all values in this map. |
| `int` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#hashCode()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#plus(androidx.wear.protolayout.expression.DynamicDataMap)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap rhs)` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#toString()()` |

## Public methods

### contains

```
public final boolean <T extends DynamicBuilders.DynamicType> contains(
    @NonNull DynamicDataKey<@NonNull T> key
)
```

Returns true if this map contains the specified `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey)` and it is associated with the specified type `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey)`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicType>` | the type to match the value's type against. Dynamic and raw types can be used interchangeably. For example `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicInt32` and `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` both return true if the associated value is of `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicInt32` type. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull T> key` | the key to check for. |

### contains

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final boolean <T extends DynamicBuilders.DynamicType> contains(
    @NonNull DynamicDataKey<@NonNull T> key,
    @NonNull Class<@NonNull T> type
)
```

Returns true if this map contains the specified `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey,java.lang.Class)` and it is associated with the specified `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#contains(androidx.wear.protolayout.expression.DynamicDataKey,java.lang.Class)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull T> key` | the key to check for. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type` | the type to match the value's type against. Dynamic and raw types can be used interchangeably. For example `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicInt32` and `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` both return true if the associated value is of `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicInt32` type. |

### equals

```
public boolean equals(Object other)
```

### get

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final Boolean get(@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicBool> key)
```

Gets the boolean value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. If there isn't any mapped value for `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`, returns null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a non-boolean value is stored with the same name as `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |

### get

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final Color get(@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicColor> key)
```

Gets the color value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. If there isn't any mapped value for `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`, returns null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a non-color value is stored with the same name as `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |

### get

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final Duration get(@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicDuration> key)
```

Gets the `https://developer.android.com/reference/java/time/Duration.html` value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. If there isn't any mapped value for `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`, returns null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a non-`https://developer.android.com/reference/java/time/Duration.html` value is stored with the same name as `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |

### get

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final Float get(@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicFloat> key)
```

Gets the float value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. If there isn't any mapped value for `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`, returns null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the key is not stored in the map. |

### get

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final Instant get(@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicInstant> key)
```

Gets the `https://developer.android.com/reference/java/time/Instant.html` value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. If there isn't any mapped value for `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`, returns null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a non-`https://developer.android.com/reference/java/time/Instant.html` value is stored with the same name as `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |

### get

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final Integer get(@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicInt32> key)
```

Gets the integer value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. If there isn't any mapped value for `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`, returns null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a non-integer value is stored with the same name as `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |

### get

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final String get(@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicString> key)
```

Gets the string value mapped to `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. If there isn't any mapped value for `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`, returns null.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a non-string value is stored with the same name as `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataMap#get(androidx.wear.protolayout.expression.DynamicDataKey)`. |

### getEntries

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull Set<@NonNull Map.Entry<@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicType>, @NonNull DynamicDataBuilders.DynamicDataValue<@NonNull DynamicBuilders.DynamicType>>> getEntries()
```

Returns a read-only `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of all key/value pairs in this map.

### getKeys

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull Set<@NonNull DynamicDataKey<@NonNull DynamicBuilders.DynamicType>> getKeys()
```

Returns a read-only `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` of all keys in this map.

### getSize

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final int getSize()
```

Returns the number of key/value pairs in the map.

### getValues

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull Collection<@NonNull DynamicDataBuilders.DynamicDataValue<@NonNull DynamicBuilders.DynamicType>> getValues()
```

Returns a read-only `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html` of all values in this map. Note that this collection may contain duplicate values.

### hashCode

```
public int hashCode()
```

### plus

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull DynamicDataMap plus(@NonNull DynamicDataMap rhs)
```

### toString

```
public @NonNull String toString()
```