# Discouraged

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

*** ** * ** ***


```
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS])
public annotation Discouraged
```

<br />

*** ** * ** ***

Denotes that the annotated element, while not disallowed or deprecated, is one that programmers are generally discouraged from using.

Example:

```
@Discouraged(message = "It is much more efficient to retrieve "
                       + "resources by identifier than by name.")
public void getValue(String name) {
    ...
}
```

## 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/Discouraged#getMessage()()` Defines the message to display when an element marked with this annotation is used. |

## Public methods

### getMessage

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

Defines the message to display when an element marked with this annotation is used. An alternative should be provided in the message.