mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Added some NonNull/Nullable in database code
This commit is contained in:
parent
dc7d5b40f2
commit
9cf63611e4
@ -4,6 +4,8 @@ import java.beans.IntrospectionException;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
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.BentoBox;
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
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.
|
* The addon that is accessing the database, if any.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private Addon addon;
|
private Addon addon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the addon that is accessing the database, if any. May be null.
|
* Get the addon that is accessing the database, if any. May be null.
|
||||||
* @return the addon
|
* @return the addon
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Addon getAddon() {
|
public Addon getAddon() {
|
||||||
return addon;
|
return addon;
|
||||||
}
|
}
|
||||||
@ -52,7 +56,7 @@ public abstract class AbstractDatabaseHandler<T> {
|
|||||||
* Set the addon that is accessing the database, if any.
|
* Set the addon that is accessing the database, if any.
|
||||||
* @param addon the addon to set
|
* @param addon the addon to set
|
||||||
*/
|
*/
|
||||||
public void setAddon(Addon addon) {
|
public void setAddon(@Nullable Addon addon) {
|
||||||
this.addon = addon;
|
this.addon = addon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +88,8 @@ public abstract class AbstractDatabaseHandler<T> {
|
|||||||
* @param uniqueId - unique ID
|
* @param uniqueId - unique ID
|
||||||
* @return <T>
|
* @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
|
* Save T into the corresponding database
|
||||||
@ -115,6 +120,7 @@ public abstract class AbstractDatabaseHandler<T> {
|
|||||||
* Attempts to delete the object with the uniqueId
|
* Attempts to delete the object with the uniqueId
|
||||||
* @param uniqueId - uniqueId of object
|
* @param uniqueId - uniqueId of object
|
||||||
* @return true if successful, false if there is no such uniqueId
|
* @return true if successful, false if there is no such uniqueId
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public abstract boolean deleteID(String uniqueId);
|
public abstract boolean deleteID(String uniqueId);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
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
|
* 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
|
* @return list of config objects or an empty list if they cannot be loaded
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
public List<T> loadObjects() {
|
public List<T> loadObjects() {
|
||||||
List<T> result = new ArrayList<>();
|
List<T> result = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user