# A2uiCoreSurfaceModel

Artifact: [androidx.a2ui:a2ui-engine](https://developer.android.com/jetpack/androidx/releases/a2ui) [View Source](https://cs.android.com/search?q=file:androidx/a2ui/engine/model/A2uiCoreSurfaceModel.kt+class:androidx.a2ui.engine.model.A2uiCoreSurfaceModel) Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

*** ** * ** ***


```
public final class A2uiCoreSurfaceModel implements A2uiSurfaceModel
```

<br />

*** ** * ** ***

The root domain model for a single active surface.

It acts as the owner of that surface's `https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreDataModel` and `https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry`, managing updates to these registries and propagating user actions and validation/runtime errors.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#A2uiCoreSurfaceModel(kotlin.String,androidx.a2ui.engine.catalog.A2uiCoreCatalog,androidx.a2ui.engine.platform.A2uiCoreDataModel,androidx.a2ui.engine.platform.A2uiCoreComponentRegistry,kotlin.Function1,kotlin.Function1,kotlin.collections.Map,kotlin.Boolean,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html id, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/catalog/A2uiCoreCatalog catalog, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreDataModel dataModel, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry componentRegistry, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiUserAction, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onDispatchAction, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiClientErrorMessage, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onDispatchError, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html> theme, boolean shouldSendDataModel, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Long.html> timeProvider )` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchAction(kotlin.String,kotlin.collections.Map)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html componentId, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html> actionDefinition )` Dispatches a user action from this surface to the registered action handler callback. |
| `final void` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchError(androidx.a2ui.model.protocol.A2uiException,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiException exception, https://developer.android.com/reference/java/lang/String.html componentId)` Reports a rendering or evaluation failure to the component registry and dispatches the error to the registered error handler callback. |
| `boolean` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#evaluatePayload(kotlin.String,androidx.a2ui.engine.model.A2uiCoreValueResolver,androidx.a2ui.model.protocol.A2uiDataPath,kotlin.Any)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html componentId, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreValueResolver valueResolver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiDataPath dataPath, https://developer.android.com/reference/java/lang/Object.html payload )` Evaluates a dynamic payload for a specific component. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/catalog/A2uiCoreCatalog` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getCatalog()()` The catalog used in this surface. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getComponentRegistry()()` The component registry backing this surface. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreDataModel` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getDataModel()()` The storage model for this surface's data tree. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getId()()` The unique identifier of this surface. |
| `@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/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html componentId, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/catalog/A2uiFunctionDefinition functionDefinition, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull T> factory )` Gets or creates a component-scoped cache for `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getTheme()()` An optional map of theme-specific overrides for this surface. |
| `int` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#hashCode()()` |
| `final boolean` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#shouldSendDataModel()()` If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#toString()()` |

## Public constructors

### A2uiCoreSurfaceModel

```
public A2uiCoreSurfaceModel(
    @NonNull String id,
    @NonNull A2uiCoreCatalog catalog,
    @NonNull A2uiCoreDataModel dataModel,
    @NonNull A2uiCoreComponentRegistry componentRegistry,
    @NonNull Function1<@NonNull A2uiUserAction, Unit> onDispatchAction,
    @NonNull Function1<@NonNull A2uiClientErrorMessage, Unit> onDispatchError,
    @NonNull Map<@NonNull String, Object> theme,
    boolean shouldSendDataModel,
    @NonNull Function0<@NonNull Long> timeProvider
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html id` | The unique identifier of this surface. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/catalog/A2uiCoreCatalog catalog` | The catalog used in this surface. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreDataModel dataModel` | The storage model for this surface's data tree. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/platform/A2uiCoreComponentRegistry componentRegistry` | The component registry backing this surface. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiUserAction, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onDispatchAction` | Callback to handle user actions dispatched from this surface. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiClientErrorMessage, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onDispatchError` | Callback to handle errors dispatched from this surface. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html> theme` | An optional map of theme-specific overrides for this surface. |
| `boolean shouldSendDataModel` | If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Long.html> timeProvider` | Provider that returns the current epoch time in milliseconds. |

## Public methods

### dispatchAction

```
public final void dispatchAction(
    @NonNull String componentId,
    @NonNull Map<@NonNull String, Object> actionDefinition
)
```

Dispatches a user action from this surface to the registered action handler callback.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html componentId` | The unique identifier of the component that was interacted with. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html> actionDefinition` | A map containing details about the action (e.g., name, context). |

### dispatchError

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public final void dispatchError(@NonNull A2uiException exception, String componentId)
```

Reports a rendering or evaluation failure to the component registry and dispatches the error to the registered error handler callback.

**Note:** The `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchError(androidx.a2ui.model.protocol.A2uiException,kotlin.String)` is exclusively used to mark the error on the local component registry for local UI error boundary rendering. It is **not** appended or injected into the exception context or path sent to the server. Callers must ensure the `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#dispatchError(androidx.a2ui.model.protocol.A2uiException,kotlin.String)` itself is initialized with all the relevant information, including the component id if relevant.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiException exception` | The exception describing the failure. |
| `https://developer.android.com/reference/java/lang/String.html componentId` | The unique identifier of the component that encountered the error. Null if the error is surface-level. |

### equals

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

### evaluatePayload

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public final Object evaluatePayload(
    @NonNull String componentId,
    @NonNull A2uiCoreValueResolver valueResolver,
    @NonNull A2uiDataPath dataPath,
    Object payload
)
```

Evaluates a dynamic payload for a specific component.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html componentId` | unique identifier of the UI component |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreValueResolver valueResolver` | resolver to retrieve values from the data model |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/protocol/A2uiDataPath dataPath` | base path used to resolve relative paths |
| `https://developer.android.com/reference/java/lang/Object.html payload` | payload to evaluate |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html` | evaluated result, or null if evaluation fails |

### getCatalog

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public final @NonNull A2uiCoreCatalog getCatalog()
```

The catalog used in this surface.

### getComponentRegistry

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public final @NonNull A2uiCoreComponentRegistry getComponentRegistry()
```

The component registry backing this surface.

### getDataModel

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public final @NonNull A2uiCoreDataModel getDataModel()
```

The storage model for this surface's data tree.

### getId

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public @NonNull String getId()
```

The unique identifier of this surface.

### getOrCreateFunctionScopedCache

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public @NonNull T <T extends Object> getOrCreateFunctionScopedCache(
    @NonNull String componentId,
    @NonNull A2uiFunctionDefinition functionDefinition,
    @NonNull Function0<@NonNull T> factory
)
```

Gets or creates a component-scoped cache for `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)`.

Each component and `https://developer.android.com/reference/androidx/a2ui/engine/model/A2uiCoreSurfaceModel#getOrCreateFunctionScopedCache(kotlin.String,androidx.a2ui.model.catalog.A2uiFunctionDefinition,kotlin.Function0)` pair gets a separate cache that persists across function invocations and data model updates. Ideal for storing the results of heavy operations that do *not* rely on data model values (e.g., static metadata, parsed templates, compiled regexes, etc.).

Warning: The cache does not refresh upon data model changes. Caching values that are based on the data model will result in a stale cache.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html componentId` | unique identifier of the component |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/a2ui/model/catalog/A2uiFunctionDefinition functionDefinition` | definition identifying the cache |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull T> factory` | factory function to create the cache if missing |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | cache instance |

### getTheme

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public final @NonNull Map<@NonNull String, Object> getTheme()
```

An optional map of theme-specific overrides for this surface.

### hashCode

```
public int hashCode()
```

### shouldSendDataModel

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/a2ui#1.0.0-alpha02)

```
public final boolean shouldSendDataModel()
```

If true, indicates the data model of this surface should be appended as metadata to outgoing messages to the server.

### toString

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