# ReplaceWith

Artifact: [androidx.annotation:annotation](https://developer.android.com/jetpack/androidx/releases/annotation) [View Source](https://cs.android.com/search?q=file:androidx/annotation/ReplaceWith.jvm.kt+class:androidx.annotation.ReplaceWith) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.8.0)

*** ** * ** ***

Common/AllAndroid/JVM
- android

  ```
  @Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.FIELD, AnnotationTarget.CONSTRUCTOR])
  annotation ReplaceWith
  ```

*** ** * ** ***

Specifies a code fragment that can be used to suggest a replacement for a method in conjunction with the `ReplaceWith` lint check.

The `expression` parameter specified the replacement expression, which is interpreted in the context of the symbol being used and can reference members of the enclosing classes, etc.

For method calls, the replacement expression may contain parameter names of the method being replaced, which will be substituted with actual arguments used in the call being replaced:

```
@ReplaceWith(expression = "event.getActionType(slot)")
static int getActionType(AccessibilityEvent event, int slot) { ... }
```

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith#ReplaceWith(kotlin.String,kotlin.Array)(expression: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, vararg imports: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` | android |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith#expression()` | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>` | `https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith#imports()` | android |

## Public constructors

### ReplaceWith

android Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/annotation#1.10.0)

```
ReplaceWith(expression: String, vararg imports: String = [])
```

## Public properties

### expression

android

```
val expression: String
```

### imports

android

```
val imports: Array<String>
```