Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-14 20:10:05 +01:00
[ci skip] Add section on nullability annotations (#11461)
Dieser Commit ist enthalten in:
Ursprung
709f0f2919
Commit
fb768404aa
@ -249,6 +249,17 @@ instead of adding a new import to the top of the file. If you are using a type a
|
|||||||
can add an import with a comment. However, if its only used a couple of times, the FQN is preferred to prevent future
|
can add an import with a comment. However, if its only used a couple of times, the FQN is preferred to prevent future
|
||||||
patch conflicts in the import section of the file.
|
patch conflicts in the import section of the file.
|
||||||
|
|
||||||
|
### Nullability annotations
|
||||||
|
|
||||||
|
We are in the process of switching nullability annotation libraries, so you might need to use one or the other:
|
||||||
|
|
||||||
|
**For classes we add**: Fields, method parameters and return types that are nullable should be marked via the
|
||||||
|
`@Nullable` annotation from `org.jspecify.annotations`. Whenever you create a new class, add `@NullMarked`, meaning types
|
||||||
|
are assumed to be non-null by default. For less obvious placing such as on generics or arrays, see the [JSpecify docs](https://jspecify.dev/docs/user-guide/).
|
||||||
|
|
||||||
|
**For classes added by upstream**: Keep using both `@Nullable` and `@NotNull` from `org.jetbrains.annotations`. These
|
||||||
|
will be replaced later.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
// don't add import here, use FQN like below
|
// don't add import here, use FQN like below
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren