Added some NonNull/Nullable in database code

This commit is contained in:
Florian CUNY 2019-01-13 10:27:36 +01:00
parent dc7d5b40f2
commit 9cf63611e4
2 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,8 @@ import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.Addon;
@ -38,12 +40,14 @@ public abstract class AbstractDatabaseHandler<T> {
/**
* The addon that is accessing the database, if any.
*/
@Nullable
private Addon addon;
/**
* Get the addon that is accessing the database, if any. May be null.
* @return the addon
*/
@Nullable
public Addon getAddon() {
return addon;
}
@ -52,7 +56,7 @@ public abstract class AbstractDatabaseHandler<T> {
* Set the addon that is accessing the database, if any.
* @param addon the addon to set
*/
public void setAddon(Addon addon) {
public void setAddon(@Nullable Addon addon) {
this.addon = addon;
}
@ -84,7 +88,8 @@ public abstract class AbstractDatabaseHandler<T> {
* @param uniqueId - unique ID
* @return <T>
*/
public abstract T loadObject(String uniqueId) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException, NoSuchMethodException;
@Nullable
public abstract T loadObject(@NonNull String uniqueId) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException, NoSuchMethodException;
/**
* Save T into the corresponding database
@ -115,6 +120,7 @@ public abstract class AbstractDatabaseHandler<T> {
* Attempts to delete the object with the uniqueId
* @param uniqueId - uniqueId of object
* @return true if successful, false if there is no such uniqueId
* @since 1.1
*/
public abstract boolean deleteID(String uniqueId);
}

View File

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.Addon;
@ -44,6 +45,7 @@ public class Database<T> {
* Load all the config objects and supply them as a list
* @return list of config objects or an empty list if they cannot be loaded
*/
@NonNull
public List<T> loadObjects() {
List<T> result = new ArrayList<>();
try {