File: AnnotationPosition.md

package info (click to toggle)
error-prone-java 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 23,204 kB
  • sloc: java: 222,992; xml: 1,319; sh: 25; makefile: 7
file content (29 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Per the [style guide](style-guide), `TYPE_USE` annotations should appear
immediately before the type being annotated, and after any modifiers:

```java
public <K, V> @Nullable V getOrNull(final Map<K, V> map, final @Nullable K key) {
  return map.get(key);
}
```

Non-`TYPE_USE` annotations should appear before modifiers, as they annotate the
entire element (method, variable, class):

```java
@VisibleForTesting
public void reset() {
  // ...
}
```

Javadoc must appear before any annotations, or the compiler will fail to
recognise it as Javadoc:

```java
@Nullable
/** Might return a frobnicator. */
Frobnicator getFrobnicator();
```

[style-guide]: https://google.github.io/styleguide/javaguide.html#s4.8.5.1-type-use-annotation-style