# 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)

*** ** * ** ***


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

<br />

*** ** * ** ***

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 methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/annotation/ReplaceWith#getExpression()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull String[]` | `https://developer.android.com/reference/androidx/annotation/ReplaceWith#getImports()()` |

## Public methods

### getExpression

```
public final @NonNull String getExpression()
```

### getImports

```
public final @NonNull String[] getImports()
```