From 57b559e81db09b7930e5f8507cb1f24313cb3704 Mon Sep 17 00:00:00 2001 From: Andrew Wong <42793301+md5sha256@users.noreply.github.com> Date: Wed, 19 May 2021 18:57:29 +0200 Subject: [PATCH] Fix nullability and docs --- .../utils/itemstack/ItemStackWrapper.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java index 922ce5109..8c0f395db 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java @@ -125,15 +125,12 @@ public final class ItemStackWrapper extends ItemStack { * will not check if the passed {@link ItemStack} has already been wrapped * * @param itemStack The {@link ItemStack} to wrap - * @return Returns null only if the passed ItemStack is null. - * Otherwise: An {@link ItemStackWrapper} of the passed {@link ItemStack} + * @return Returns an {@link ItemStackWrapper} of the passed {@link ItemStack} * @see #wrap(ItemStack) */ - @Nullable - public static ItemStackWrapper forceWrap(@Nullable ItemStack itemStack) { - if (itemStack == null) { - return null; - } + @Nonnull + public static ItemStackWrapper forceWrap(@Nonnull ItemStack itemStack) { + Validate.notNull(itemStack, "The ItemStack cannot be null!"); return new ItemStackWrapper(itemStack); } @@ -143,15 +140,13 @@ public final class ItemStackWrapper extends ItemStack { * is already an {@link ItemStackWrapper} * * @param itemStack The {@link ItemStack} to wrap - * @return Returns null only if the passed ItemStack is null. - * Otherwise: An {@link ItemStackWrapper} of the passed {@link ItemStack} + * @return Returns an {@link ItemStackWrapper} of the passed {@link ItemStack} * @see #forceWrap(ItemStack) */ - @Nullable - public static ItemStackWrapper wrap(@Nullable ItemStack itemStack) { - if (itemStack == null) { - return null; - } else if (itemStack instanceof ItemStackWrapper) { + @Nonnull + public static ItemStackWrapper wrap(@Nonnull ItemStack itemStack) { + Validate.notNull(itemStack, "The ItemStack cannot be null!"); + if (itemStack instanceof ItemStackWrapper) { return (ItemStackWrapper) itemStack; } return new ItemStackWrapper(itemStack);