SPIGOT-2540: Add nullability annotations to entire Bukkit API

By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
Bukkit/Spigot
2019-03-13 17:42:57 +11:00
parent e069a80fd8
commit 416c865476
565 changed files with 5372 additions and 2008 deletions

View File

@@ -9,6 +9,7 @@ import org.bukkit.configuration.serialization.SerializableAs;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
/**
* Represents a single firework effect.
@@ -48,6 +49,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
*
* @return A utility object for building a firework effect
*/
@NotNull
public static Builder builder() {
return new Builder();
}
@@ -73,7 +75,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @return This object, for chaining
* @throws IllegalArgumentException If type is null
*/
public Builder with(Type type) throws IllegalArgumentException {
@NotNull
public Builder with(@NotNull Type type) throws IllegalArgumentException {
Validate.notNull(type, "Cannot have null type");
this.type = type;
return this;
@@ -84,6 +87,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
*
* @return This object, for chaining
*/
@NotNull
public Builder withFlicker() {
flicker = true;
return this;
@@ -95,6 +99,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @param flicker true if it should flicker, false if not
* @return This object, for chaining
*/
@NotNull
public Builder flicker(boolean flicker) {
this.flicker = flicker;
return this;
@@ -105,6 +110,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
*
* @return This object, for chaining
*/
@NotNull
public Builder withTrail() {
trail = true;
return this;
@@ -116,6 +122,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @param trail true if it should have a trail, false for no trail
* @return This object, for chaining
*/
@NotNull
public Builder trail(boolean trail) {
this.trail = trail;
return this;
@@ -128,7 +135,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @return This object, for chaining
* @throws IllegalArgumentException If color is null
*/
public Builder withColor(Color color) throws IllegalArgumentException {
@NotNull
public Builder withColor(@NotNull Color color) throws IllegalArgumentException {
Validate.notNull(color, "Cannot have null color");
colors.add(color);
@@ -145,7 +153,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @throws IllegalArgumentException If any color is null (may be
* thrown after changes have occurred)
*/
public Builder withColor(Color... colors) throws IllegalArgumentException {
@NotNull
public Builder withColor(@NotNull Color... colors) throws IllegalArgumentException {
Validate.notNull(colors, "Cannot have null colors");
if (colors.length == 0) {
return this;
@@ -170,7 +179,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @throws IllegalArgumentException If any color is null (may be
* thrown after changes have occurred)
*/
public Builder withColor(Iterable<?> colors) throws IllegalArgumentException {
@NotNull
public Builder withColor(@NotNull Iterable<?> colors) throws IllegalArgumentException {
Validate.notNull(colors, "Cannot have null colors");
ImmutableList.Builder<Color> list = this.colors;
@@ -193,7 +203,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @throws IllegalArgumentException If any color is null (may be
* thrown after changes have occurred)
*/
public Builder withFade(Color color) throws IllegalArgumentException {
@NotNull
public Builder withFade(@NotNull Color color) throws IllegalArgumentException {
Validate.notNull(color, "Cannot have null color");
if (fadeColors == null) {
@@ -214,7 +225,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @throws IllegalArgumentException If any color is null (may be
* thrown after changes have occurred)
*/
public Builder withFade(Color... colors) throws IllegalArgumentException {
@NotNull
public Builder withFade(@NotNull Color... colors) throws IllegalArgumentException {
Validate.notNull(colors, "Cannot have null colors");
if (colors.length == 0) {
return this;
@@ -243,7 +255,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @throws IllegalArgumentException If any color is null (may be
* thrown after changes have occurred)
*/
public Builder withFade(Iterable<?> colors) throws IllegalArgumentException {
@NotNull
public Builder withFade(@NotNull Iterable<?> colors) throws IllegalArgumentException {
Validate.notNull(colors, "Cannot have null colors");
ImmutableList.Builder<Color> list = this.fadeColors;
@@ -269,6 +282,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
*
* @return The representative firework effect
*/
@NotNull
public FireworkEffect build() {
return new FireworkEffect(
flicker,
@@ -293,7 +307,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
private final Type type;
private String string = null;
FireworkEffect(boolean flicker, boolean trail, ImmutableList<Color> colors, ImmutableList<Color> fadeColors, Type type) {
FireworkEffect(boolean flicker, boolean trail, @NotNull ImmutableList<Color> colors, @NotNull ImmutableList<Color> fadeColors, @NotNull Type type) {
if (colors.isEmpty()) {
throw new IllegalStateException("Cannot make FireworkEffect without any color");
}
@@ -327,6 +341,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
*
* @return An immutable list of the primary colors
*/
@NotNull
public List<Color> getColors() {
return colors;
}
@@ -336,6 +351,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
*
* @return An immutable list of the fade colors
*/
@NotNull
public List<Color> getFadeColors() {
return fadeColors;
}
@@ -345,6 +361,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
*
* @return The effect type
*/
@NotNull
public Type getType() {
return type;
}
@@ -354,7 +371,8 @@ public final class FireworkEffect implements ConfigurationSerializable {
* @param map the map to deserialize
* @return the resulting serializable
*/
public static ConfigurationSerializable deserialize(Map<String, Object> map) {
@NotNull
public static ConfigurationSerializable deserialize(@NotNull Map<String, Object> map) {
Type type = Type.valueOf((String) map.get(TYPE));
return builder()
@@ -366,6 +384,7 @@ public final class FireworkEffect implements ConfigurationSerializable {
.build();
}
@NotNull
@Override
public Map<String, Object> serialize() {
return ImmutableMap.<String, Object>of(