SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -9,6 +9,8 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a section of a {@link Configuration}
|
||||
@@ -28,6 +30,7 @@ public interface ConfigurationSection {
|
||||
* list.
|
||||
* @return Set of keys contained within this ConfigurationSection.
|
||||
*/
|
||||
@NotNull
|
||||
public Set<String> getKeys(boolean deep);
|
||||
|
||||
/**
|
||||
@@ -44,6 +47,7 @@ public interface ConfigurationSection {
|
||||
* list.
|
||||
* @return Map of keys and values of this section.
|
||||
*/
|
||||
@NotNull
|
||||
public Map<String, Object> getValues(boolean deep);
|
||||
|
||||
/**
|
||||
@@ -57,7 +61,7 @@ public interface ConfigurationSection {
|
||||
* default or being set.
|
||||
* @throws IllegalArgumentException Thrown when path is null.
|
||||
*/
|
||||
public boolean contains(String path);
|
||||
public boolean contains(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Checks if this {@link ConfigurationSection} contains the given path.
|
||||
@@ -76,7 +80,7 @@ public interface ConfigurationSection {
|
||||
* value exist and the boolean parameter for this method is true.
|
||||
* @throws IllegalArgumentException Thrown when path is null.
|
||||
*/
|
||||
public boolean contains(String path, boolean ignoreDefault);
|
||||
public boolean contains(@NotNull String path, boolean ignoreDefault);
|
||||
|
||||
/**
|
||||
* Checks if this {@link ConfigurationSection} has a value set for the
|
||||
@@ -90,7 +94,7 @@ public interface ConfigurationSection {
|
||||
* having a default.
|
||||
* @throws IllegalArgumentException Thrown when path is null.
|
||||
*/
|
||||
public boolean isSet(String path);
|
||||
public boolean isSet(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the path of this {@link ConfigurationSection} from its root {@link
|
||||
@@ -107,6 +111,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Path of this section relative to its root
|
||||
*/
|
||||
@Nullable
|
||||
public String getCurrentPath();
|
||||
|
||||
/**
|
||||
@@ -118,6 +123,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Name of this section
|
||||
*/
|
||||
@NotNull
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
@@ -132,6 +138,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Root configuration containing this section.
|
||||
*/
|
||||
@Nullable
|
||||
public Configuration getRoot();
|
||||
|
||||
/**
|
||||
@@ -145,6 +152,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Parent section containing this section.
|
||||
*/
|
||||
@Nullable
|
||||
public ConfigurationSection getParent();
|
||||
|
||||
/**
|
||||
@@ -157,7 +165,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the Object to get.
|
||||
* @return Requested Object.
|
||||
*/
|
||||
public Object get(String path);
|
||||
@Nullable
|
||||
public Object get(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested Object by path, returning a default value if not
|
||||
@@ -171,7 +180,8 @@ public interface ConfigurationSection {
|
||||
* @param def The default value to return if the path is not found.
|
||||
* @return Requested Object.
|
||||
*/
|
||||
public Object get(String path, Object def);
|
||||
@Nullable
|
||||
public Object get(@NotNull String path, @Nullable Object def);
|
||||
|
||||
/**
|
||||
* Sets the specified path to the given value.
|
||||
@@ -187,7 +197,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the object to set.
|
||||
* @param value New value to set the path to.
|
||||
*/
|
||||
public void set(String path, Object value);
|
||||
public void set(@NotNull String path, @Nullable Object value);
|
||||
|
||||
/**
|
||||
* Creates an empty {@link ConfigurationSection} at the specified path.
|
||||
@@ -199,7 +209,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path to create the section at.
|
||||
* @return Newly created section
|
||||
*/
|
||||
public ConfigurationSection createSection(String path);
|
||||
@NotNull
|
||||
public ConfigurationSection createSection(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Creates a {@link ConfigurationSection} at the specified path, with
|
||||
@@ -213,7 +224,8 @@ public interface ConfigurationSection {
|
||||
* @param map The values to used.
|
||||
* @return Newly created section
|
||||
*/
|
||||
public ConfigurationSection createSection(String path, Map<?, ?> map);
|
||||
@NotNull
|
||||
public ConfigurationSection createSection(@NotNull String path, @NotNull Map<?, ?> map);
|
||||
|
||||
// Primitives
|
||||
/**
|
||||
@@ -226,7 +238,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the String to get.
|
||||
* @return Requested String.
|
||||
*/
|
||||
public String getString(String path);
|
||||
@Nullable
|
||||
public String getString(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested String by path, returning a default value if not
|
||||
@@ -241,7 +254,8 @@ public interface ConfigurationSection {
|
||||
* not a String.
|
||||
* @return Requested String.
|
||||
*/
|
||||
public String getString(String path, String def);
|
||||
@Nullable
|
||||
public String getString(@NotNull String path, @Nullable String def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a String.
|
||||
@@ -254,7 +268,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the String to check.
|
||||
* @return Whether or not the specified path is a String.
|
||||
*/
|
||||
public boolean isString(String path);
|
||||
public boolean isString(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested int by path.
|
||||
@@ -266,7 +280,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the int to get.
|
||||
* @return Requested int.
|
||||
*/
|
||||
public int getInt(String path);
|
||||
public int getInt(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested int by path, returning a default value if not found.
|
||||
@@ -280,7 +294,7 @@ public interface ConfigurationSection {
|
||||
* not an int.
|
||||
* @return Requested int.
|
||||
*/
|
||||
public int getInt(String path, int def);
|
||||
public int getInt(@NotNull String path, int def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is an int.
|
||||
@@ -293,7 +307,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the int to check.
|
||||
* @return Whether or not the specified path is an int.
|
||||
*/
|
||||
public boolean isInt(String path);
|
||||
public boolean isInt(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested boolean by path.
|
||||
@@ -305,7 +319,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the boolean to get.
|
||||
* @return Requested boolean.
|
||||
*/
|
||||
public boolean getBoolean(String path);
|
||||
public boolean getBoolean(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested boolean by path, returning a default value if not
|
||||
@@ -320,7 +334,7 @@ public interface ConfigurationSection {
|
||||
* not a boolean.
|
||||
* @return Requested boolean.
|
||||
*/
|
||||
public boolean getBoolean(String path, boolean def);
|
||||
public boolean getBoolean(@NotNull String path, boolean def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a boolean.
|
||||
@@ -333,7 +347,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the boolean to check.
|
||||
* @return Whether or not the specified path is a boolean.
|
||||
*/
|
||||
public boolean isBoolean(String path);
|
||||
public boolean isBoolean(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested double by path.
|
||||
@@ -345,7 +359,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the double to get.
|
||||
* @return Requested double.
|
||||
*/
|
||||
public double getDouble(String path);
|
||||
public double getDouble(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested double by path, returning a default value if not
|
||||
@@ -360,7 +374,7 @@ public interface ConfigurationSection {
|
||||
* not a double.
|
||||
* @return Requested double.
|
||||
*/
|
||||
public double getDouble(String path, double def);
|
||||
public double getDouble(@NotNull String path, double def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a double.
|
||||
@@ -373,7 +387,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the double to check.
|
||||
* @return Whether or not the specified path is a double.
|
||||
*/
|
||||
public boolean isDouble(String path);
|
||||
public boolean isDouble(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested long by path.
|
||||
@@ -385,7 +399,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the long to get.
|
||||
* @return Requested long.
|
||||
*/
|
||||
public long getLong(String path);
|
||||
public long getLong(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested long by path, returning a default value if not
|
||||
@@ -400,7 +414,7 @@ public interface ConfigurationSection {
|
||||
* not a long.
|
||||
* @return Requested long.
|
||||
*/
|
||||
public long getLong(String path, long def);
|
||||
public long getLong(@NotNull String path, long def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a long.
|
||||
@@ -413,7 +427,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the long to check.
|
||||
* @return Whether or not the specified path is a long.
|
||||
*/
|
||||
public boolean isLong(String path);
|
||||
public boolean isLong(@NotNull String path);
|
||||
|
||||
// Java
|
||||
/**
|
||||
@@ -426,7 +440,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List.
|
||||
*/
|
||||
public List<?> getList(String path);
|
||||
@Nullable
|
||||
public List<?> getList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List by path, returning a default value if not
|
||||
@@ -441,7 +456,8 @@ public interface ConfigurationSection {
|
||||
* not a List.
|
||||
* @return Requested List.
|
||||
*/
|
||||
public List<?> getList(String path, List<?> def);
|
||||
@Nullable
|
||||
public List<?> getList(@NotNull String path, @Nullable List<?> def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a List.
|
||||
@@ -454,7 +470,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to check.
|
||||
* @return Whether or not the specified path is a List.
|
||||
*/
|
||||
public boolean isList(String path);
|
||||
public boolean isList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of String by path.
|
||||
@@ -469,7 +485,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of String.
|
||||
*/
|
||||
public List<String> getStringList(String path);
|
||||
@NotNull
|
||||
public List<String> getStringList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Integer by path.
|
||||
@@ -484,7 +501,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Integer.
|
||||
*/
|
||||
public List<Integer> getIntegerList(String path);
|
||||
@NotNull
|
||||
public List<Integer> getIntegerList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Boolean by path.
|
||||
@@ -499,7 +517,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Boolean.
|
||||
*/
|
||||
public List<Boolean> getBooleanList(String path);
|
||||
@NotNull
|
||||
public List<Boolean> getBooleanList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Double by path.
|
||||
@@ -514,7 +533,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Double.
|
||||
*/
|
||||
public List<Double> getDoubleList(String path);
|
||||
@NotNull
|
||||
public List<Double> getDoubleList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Float by path.
|
||||
@@ -529,7 +549,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Float.
|
||||
*/
|
||||
public List<Float> getFloatList(String path);
|
||||
@NotNull
|
||||
public List<Float> getFloatList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Long by path.
|
||||
@@ -544,7 +565,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Long.
|
||||
*/
|
||||
public List<Long> getLongList(String path);
|
||||
@NotNull
|
||||
public List<Long> getLongList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Byte by path.
|
||||
@@ -559,7 +581,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Byte.
|
||||
*/
|
||||
public List<Byte> getByteList(String path);
|
||||
@NotNull
|
||||
public List<Byte> getByteList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Character by path.
|
||||
@@ -574,7 +597,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Character.
|
||||
*/
|
||||
public List<Character> getCharacterList(String path);
|
||||
@NotNull
|
||||
public List<Character> getCharacterList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Short by path.
|
||||
@@ -589,7 +613,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Short.
|
||||
*/
|
||||
public List<Short> getShortList(String path);
|
||||
@NotNull
|
||||
public List<Short> getShortList(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested List of Maps by path.
|
||||
@@ -604,7 +629,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Maps.
|
||||
*/
|
||||
public List<Map<?, ?>> getMapList(String path);
|
||||
@NotNull
|
||||
public List<Map<?, ?>> getMapList(@NotNull String path);
|
||||
|
||||
// Bukkit
|
||||
/**
|
||||
@@ -620,7 +646,8 @@ public interface ConfigurationSection {
|
||||
* @param clazz the type of {@link ConfigurationSerializable}
|
||||
* @return Requested {@link ConfigurationSerializable} object
|
||||
*/
|
||||
public <T extends ConfigurationSerializable> T getSerializable(String path, Class<T> clazz);
|
||||
@Nullable
|
||||
public <T extends ConfigurationSerializable> T getSerializable(@NotNull String path, @NotNull Class<T> clazz);
|
||||
|
||||
/**
|
||||
* Gets the requested {@link ConfigurationSerializable} object at the given
|
||||
@@ -637,7 +664,8 @@ public interface ConfigurationSection {
|
||||
* the path
|
||||
* @return Requested {@link ConfigurationSerializable} object
|
||||
*/
|
||||
public <T extends ConfigurationSerializable> T getSerializable(String path, Class<T> clazz, T def);
|
||||
@Nullable
|
||||
public <T extends ConfigurationSerializable> T getSerializable(@NotNull String path, @NotNull Class<T> clazz, @Nullable T def);
|
||||
|
||||
/**
|
||||
* Gets the requested Vector by path.
|
||||
@@ -649,7 +677,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the Vector to get.
|
||||
* @return Requested Vector.
|
||||
*/
|
||||
public Vector getVector(String path);
|
||||
@Nullable
|
||||
public Vector getVector(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested {@link Vector} by path, returning a default value if
|
||||
@@ -664,7 +693,8 @@ public interface ConfigurationSection {
|
||||
* not a Vector.
|
||||
* @return Requested Vector.
|
||||
*/
|
||||
public Vector getVector(String path, Vector def);
|
||||
@Nullable
|
||||
public Vector getVector(@NotNull String path, @Nullable Vector def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a Vector.
|
||||
@@ -677,7 +707,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the Vector to check.
|
||||
* @return Whether or not the specified path is a Vector.
|
||||
*/
|
||||
public boolean isVector(String path);
|
||||
public boolean isVector(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested OfflinePlayer by path.
|
||||
@@ -690,7 +720,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the OfflinePlayer to get.
|
||||
* @return Requested OfflinePlayer.
|
||||
*/
|
||||
public OfflinePlayer getOfflinePlayer(String path);
|
||||
@Nullable
|
||||
public OfflinePlayer getOfflinePlayer(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested {@link OfflinePlayer} by path, returning a default
|
||||
@@ -705,7 +736,8 @@ public interface ConfigurationSection {
|
||||
* not an OfflinePlayer.
|
||||
* @return Requested OfflinePlayer.
|
||||
*/
|
||||
public OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def);
|
||||
@Nullable
|
||||
public OfflinePlayer getOfflinePlayer(@NotNull String path, @Nullable OfflinePlayer def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is an OfflinePlayer.
|
||||
@@ -718,7 +750,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the OfflinePlayer to check.
|
||||
* @return Whether or not the specified path is an OfflinePlayer.
|
||||
*/
|
||||
public boolean isOfflinePlayer(String path);
|
||||
public boolean isOfflinePlayer(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested ItemStack by path.
|
||||
@@ -730,7 +762,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the ItemStack to get.
|
||||
* @return Requested ItemStack.
|
||||
*/
|
||||
public ItemStack getItemStack(String path);
|
||||
@Nullable
|
||||
public ItemStack getItemStack(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested {@link ItemStack} by path, returning a default value
|
||||
@@ -745,7 +778,8 @@ public interface ConfigurationSection {
|
||||
* not an ItemStack.
|
||||
* @return Requested ItemStack.
|
||||
*/
|
||||
public ItemStack getItemStack(String path, ItemStack def);
|
||||
@Nullable
|
||||
public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is an ItemStack.
|
||||
@@ -758,7 +792,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the ItemStack to check.
|
||||
* @return Whether or not the specified path is an ItemStack.
|
||||
*/
|
||||
public boolean isItemStack(String path);
|
||||
public boolean isItemStack(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested Color by path.
|
||||
@@ -770,7 +804,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the Color to get.
|
||||
* @return Requested Color.
|
||||
*/
|
||||
public Color getColor(String path);
|
||||
@Nullable
|
||||
public Color getColor(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested {@link Color} by path, returning a default value if
|
||||
@@ -785,7 +820,8 @@ public interface ConfigurationSection {
|
||||
* not a Color.
|
||||
* @return Requested Color.
|
||||
*/
|
||||
public Color getColor(String path, Color def);
|
||||
@Nullable
|
||||
public Color getColor(@NotNull String path, @Nullable Color def);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a Color.
|
||||
@@ -798,7 +834,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the Color to check.
|
||||
* @return Whether or not the specified path is a Color.
|
||||
*/
|
||||
public boolean isColor(String path);
|
||||
public boolean isColor(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the requested ConfigurationSection by path.
|
||||
@@ -811,7 +847,8 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the ConfigurationSection to get.
|
||||
* @return Requested ConfigurationSection.
|
||||
*/
|
||||
public ConfigurationSection getConfigurationSection(String path);
|
||||
@Nullable
|
||||
public ConfigurationSection getConfigurationSection(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a ConfigurationSection.
|
||||
@@ -825,7 +862,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the ConfigurationSection to check.
|
||||
* @return Whether or not the specified path is a ConfigurationSection.
|
||||
*/
|
||||
public boolean isConfigurationSection(String path);
|
||||
public boolean isConfigurationSection(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Gets the equivalent {@link ConfigurationSection} from the default
|
||||
@@ -837,6 +874,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Equivalent section in root configuration
|
||||
*/
|
||||
@Nullable
|
||||
public ConfigurationSection getDefaultSection();
|
||||
|
||||
/**
|
||||
@@ -857,5 +895,5 @@ public interface ConfigurationSection {
|
||||
* @param value Value to set the default to.
|
||||
* @throws IllegalArgumentException Thrown if path is null.
|
||||
*/
|
||||
public void addDefault(String path, Object value);
|
||||
public void addDefault(@NotNull String path, @Nullable Object value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user