# SemanticsPropertyKey

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/semantics/SemanticsProperties.kt+class:androidx.compose.ui.semantics.SemanticsPropertyKey) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  class SemanticsPropertyKey<T : Any?>
  ```

*** ** * ** ***

SemanticsPropertyKey is the infrastructure for setting key/value pairs inside semantics blocks in a type-safe way. Each key has one particular statically defined value type T.

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyKey#SemanticsPropertyKey(kotlin.String,kotlin.Function2)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, mergePolicy: (T, T?) -> T?)` | Cmn |

| ### Public functions |
|---|---|---|
| `operator T` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyKey#getValue(androidx.compose.ui.semantics.SemanticsPropertyReceiver,kotlin.reflect.KProperty)(thisRef: https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyReceiver, property: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-property/index.html<*>)` Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html`. | Cmn |
| `T?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyKey#merge(kotlin.Any,kotlin.Any)(parentValue: T?, childValue: T)` Method implementing the semantics merge policy of a particular key. | Cmn |
| `operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyKey#setValue(androidx.compose.ui.semantics.SemanticsPropertyReceiver,kotlin.reflect.KProperty,kotlin.Any)( thisRef: https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyReceiver, property: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-property/index.html<*>, value: T )` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyKey#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyKey#name()` The name of the property. | Cmn |

## Public constructors

### SemanticsPropertyKey

Cmn

```
<T : Any?> SemanticsPropertyKey(
    name: String,
    mergePolicy: (T, T?) -> T? = { parentValue, childValue ->
        parentValue ?: childValue
    }
)
```

## Public functions

### getValue

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
operator fun getValue(thisRef: SemanticsPropertyReceiver, property: KProperty<*>): T
```

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html`. Should not be called.

### merge

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun merge(parentValue: T?, childValue: T): T?
```

Method implementing the semantics merge policy of a particular key.

When mergeDescendants is set on a semantics node, then this function will called for each descendant node of a given key in depth-first-search order. The parent value accumulates the result of merging the values seen so far, similar to reduce().

The default implementation returns the parent value if one exists, otherwise uses the child element. This means by default, a SemanticsNode with mergeDescendants = true winds up with the first value found for each key in its subtree in depth-first-search order.

### setValue

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
operator fun setValue(
    thisRef: SemanticsPropertyReceiver,
    property: KProperty<*>,
    value: T
): Unit
```

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### name

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val name: String
```

The name of the property. Should be the same as the constant from which it is accessed.