Metadata.Key


public final class Metadata.Key<T extends Object>


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 extends Object>

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

Summary

Public methods

final @NonNull String

The unique string name identifying this key.

final @NonNull Class<@NonNull T>

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

@NonNull String

Public methods

getName

Added in 1.7.0-alpha03
public final @NonNull String getName()

The unique string name identifying this key.

getType

Added in 1.7.0-alpha03
public final @NonNull Class<@NonNull T> getType()

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

toString

public @NonNull String toString()