# Metadata

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/Metadata.kt+class:androidx.camera.common.Metadata) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
public interface Metadata
```

<br />

Known direct subclasses [CameraCharacteristicsMetadata](https://developer.android.com/reference/androidx/camera/common/CameraCharacteristicsMetadata), [CaptureRequestMetadata](https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata), [CaptureResultMetadata](https://developer.android.com/reference/androidx/camera/common/CaptureResultMetadata)

|---|---|
| `https://developer.android.com/reference/androidx/camera/common/CameraCharacteristicsMetadata` | An interface that provides compatibility-focused, read-only query access to `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html`. |
| `https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata` | An interface that provides compatibility-focused, read-only query access to the settings applied to a camera capture request. |
| `https://developer.android.com/reference/androidx/camera/common/CaptureResultMetadata` | An interface that provides compatibility-focused, read-only query access to the results of a single image capture. |

Known indirect subclasses [CameraCharacteristicsWrapper](https://developer.android.com/reference/androidx/camera/common/CameraCharacteristicsWrapper), [CameraExtensionCharacteristicsWrapper](https://developer.android.com/reference/androidx/camera/common/CameraExtensionCharacteristicsWrapper), [CaptureRequestWrapper](https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper), [CaptureResultWrapper](https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper), [FakeCameraCharacteristics](https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraCharacteristics), [FakeCameraExtensionCharacteristics](https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraExtensionCharacteristics), [FakeCaptureRequest](https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureRequest), [FakeCaptureResult](https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureResult)

|---|---|
| `https://developer.android.com/reference/androidx/camera/common/CameraCharacteristicsWrapper` | Wrapper interface providing compatibility-focused access to `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html`. |
| `https://developer.android.com/reference/androidx/camera/common/CameraExtensionCharacteristicsWrapper` | Compatibility wrapper around `https://developer.android.com/reference/android/hardware/camera2/CameraExtensionCharacteristics.html`. |
| `https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper` | A wrapper interface representing the settings applied to a specific camera capture request. |
| `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper` | A wrapper interface providing compatibility-focused access to `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html` and custom metadata. |
| `https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraCharacteristics` | A fake implementation of `https://developer.android.com/reference/androidx/camera/common/CameraCharacteristicsWrapper` for testing. |
| `https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraExtensionCharacteristics` | A fake implementation of `https://developer.android.com/reference/androidx/camera/common/CameraExtensionCharacteristicsWrapper` for testing. |
| `https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureRequest` | A fake implementation of `https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper` designed for unit testing. |
| `https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureResult` | A fake implementation of `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper` for testing. |

*** ** * ** ***

A read-only, map-like interface for accessing unified camera metadata.

This interface serves as the common base for metadata containers in the Camera common library, such as `https://developer.android.com/reference/androidx/camera/common/CameraCharacteristicsWrapper`, `https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper`, and `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper`.

It provides type-safe access to library-defined custom keys (`https://developer.android.com/reference/androidx/camera/common/Metadata.Key`) in addition to the platform-specific keys supported by its sub-interfaces.

### Key Concepts

- **Unified Access:** Allows combining native camera metadata (from the Android Camera2 API) with custom, internally-computed, or version-compatibility properties.

- **Read-Only:** The container's contents cannot be modified through this interface.

- **Type-Safety:** Values are retrieved using strongly-typed `https://developer.android.com/reference/androidx/camera/common/Metadata.Key` instances.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/camera/common/Metadata.Key<T extends https://developer.android.com/reference/java/lang/Object.html>` A type-safe key used to identify and retrieve values from a `https://developer.android.com/reference/androidx/camera/common/Metadata` container. |

| ### Public methods |
|---|---|
| `abstract T` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/Metadata#get(androidx.camera.common.Metadata.Key)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key)` Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`. |
| `abstract @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/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull ?>>` | `https://developer.android.com/reference/androidx/camera/common/Metadata#getMetadataKeys()()` The set of all custom `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`s currently available in this container. |
| `default @https://developer.android.com/reference/androidx/annotation/NonNull T` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key, @https://developer.android.com/reference/androidx/annotation/NonNull T default )` Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`, or returns `https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)` if the key is not present. |

## Public methods

### get

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
abstract T <T extends Object> get(@NonNull Metadata.Key<@NonNull T> key)
```

Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | The type of the value (must be non-nullable). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key` | The custom key to query. |

| Returns |
|---|---|
| `T` | The value associated with the key, or `null` if the key is not present in this container or if its value is not set. |

### getMetadataKeys

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
abstract @NonNull Set<@NonNull Metadata.Key<@NonNull ?>> getMetadataKeys()
```

The set of all custom `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`s currently available in this container.

Note that this set contains *only* custom library-defined keys. It does not include platform-specific keys (such as `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html` or `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`), which are managed separately by the implementing wrappers.

### getOrDefault

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
default @NonNull T <T extends Object> getOrDefault(
    @NonNull Metadata.Key<@NonNull T> key,
    @NonNull T default
)
```

Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`, or returns `https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)` if the key is not present.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | The type of the value (must be non-nullable). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key` | The custom key to query. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull T default` | The value to return if the key is not present or if its value is `null`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | The value associated with the key, or `https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)` if the value is not present. |