> Documentation index: https://developer.android.com/reference/llms.txt

# Metadata

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

*** ** * ** ***


```
public interface Metadata
```

<br />

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

|---|---|
| `CameraCharacteristicsMetadata` | An interface that provides compatibility-focused, read-only query access to `CameraCharacteristics`. |
| `CaptureRequestMetadata` | An interface that provides compatibility-focused, read-only query access to the settings applied to a camera capture request. |
| `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.md.txt), [CameraExtensionCharacteristicsWrapper](https://developer.android.com/reference/androidx/camera/common/CameraExtensionCharacteristicsWrapper.md.txt), [CaptureRequestWrapper](https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper.md.txt), [CaptureResultWrapper](https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper.md.txt), [FakeCameraCharacteristics](https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraCharacteristics.md.txt), [FakeCameraExtensionCharacteristics](https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraExtensionCharacteristics.md.txt), [FakeCaptureRequest](https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureRequest.md.txt), [FakeCaptureResult](https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureResult.md.txt)

|---|---|
| `CameraCharacteristicsWrapper` | Wrapper interface providing compatibility-focused access to `CameraCharacteristics`. |
| `CameraExtensionCharacteristicsWrapper` | Compatibility wrapper around `CameraExtensionCharacteristics`. |
| `CaptureRequestWrapper` | A wrapper interface representing the settings applied to a specific camera capture request. |
| `CaptureResultWrapper` | A wrapper interface providing compatibility-focused access to `CaptureResult` and custom metadata. |
| `FakeCameraCharacteristics` | A fake implementation of `CameraCharacteristicsWrapper` for testing. |
| `FakeCameraExtensionCharacteristics` | A fake implementation of `CameraExtensionCharacteristicsWrapper` for testing. |
| `FakeCaptureRequest` | A fake implementation of `CaptureRequestWrapper` designed for unit testing. |
| `FakeCaptureResult` | A fake implementation of `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 `CameraCharacteristicsWrapper`, `CaptureRequestWrapper`, and `CaptureResultWrapper`.

It provides type-safe access to library-defined custom keys (`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 `Key` instances.

## Summary

| ### Nested types |
|---|
| `public final class Metadata.Key<T extends Object>` A type-safe key used to identify and retrieve values from a `Metadata` container. |

| ### Public methods |
|---|---|
| `abstract T` | `<T extends Object> get(@NonNull Metadata.Key<@NonNull T> key)` Retrieves the value associated with the specified `Metadata.Key`. |
| `abstract @NonNull Set<@NonNull Metadata.Key<@NonNull ?>>` | `getMetadataKeys()` The set of all custom `Metadata.Key`s currently available in this container. |
| `default @NonNull T` | `<T extends Object> getOrDefault( @NonNull Metadata.Key<@NonNull T> key, @NonNull T default )` Retrieves the value associated with the specified `Metadata.Key`, or returns `default` if the key is not present. |

## Public methods

### get

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

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

Retrieves the value associated with the specified `Metadata.Key`.

| Parameters |
|---|---|
| `<T extends Object>` | The type of the value (must be non-nullable). |
| `@NonNull Metadata.Key<@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](https://developer.android.com/jetpack/androidx/releases/camera.md.txt#1.7.0)

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

The set of all custom `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 `android.hardware.camera2.CameraCharacteristics.Key` or `android.hardware.camera2.CaptureResult.Key`), which are managed separately by the implementing wrappers.

### getOrDefault

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

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

Retrieves the value associated with the specified `Metadata.Key`, or returns `default` if the key is not present.

| Parameters |
|---|---|
| `<T extends Object>` | The type of the value (must be non-nullable). |
| `@NonNull Metadata.Key<@NonNull T> key` | The custom key to query. |
| `@NonNull T default` | The value to return if the key is not present or if its value is `null`. |

| Returns |
|---|---|
| `@NonNull T` | The value associated with the key, or `default` if the value is not present. |