Metadata.Key


class Metadata.Key<T : Any>


A type-safe key used to identify and retrieve values from a Metadata container.

Keys are unique by their name. Only one Key instance can exist for a given name. Attempting to create a key with an existing name but a different type will throw an IllegalStateException.

!IMPORTANT Creating new Key instances is restricted to the AndroidX Camera library group. External clients can use predefined keys but cannot define their own.

Examples (Internal Library Usage Only)

Creating keys in Kotlin:

// For primitive/standard types:
val widthKey = Metadata.Key<Int>("androidx.camera.width")
val nameKey = Metadata.Key<String>("androidx.camera.name")

// For custom classes:
class MyConfig(val value: String)
val configKey = Metadata.Key<MyConfig>("androidx.camera.config")
Parameters
<T : Any>

The type of the value associated with this key (must be non-nullable).

Summary

Public functions

open String

Public properties

String

The unique string name identifying this key.

Class<T>

The Class representing the type of the value associated with this key.

Public functions

toString

open fun toString(): String

Public properties

name

Added in 1.7.0-alpha03
val nameString

The unique string name identifying this key.

type

Added in 1.7.0-alpha03
val typeClass<T>

The Class representing the type of the value associated with this key.