1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Fix nullability and docs

This commit is contained in:
Andrew Wong 2021-05-19 18:57:29 +02:00
parent 7e43e68f68
commit 57b559e81d
No known key found for this signature in database
GPG Key ID: F59F2C3DA0936DE4

View File

@ -125,15 +125,12 @@ public final class ItemStackWrapper extends ItemStack {
* will not check if the passed {@link ItemStack} has already been wrapped * will not check if the passed {@link ItemStack} has already been wrapped
* *
* @param itemStack The {@link ItemStack} to wrap * @param itemStack The {@link ItemStack} to wrap
* @return Returns <code>null</code> only if the passed ItemStack is <code>null</code>. * @return Returns an {@link ItemStackWrapper} of the passed {@link ItemStack}
* Otherwise: An {@link ItemStackWrapper} of the passed {@link ItemStack}
* @see #wrap(ItemStack) * @see #wrap(ItemStack)
*/ */
@Nullable @Nonnull
public static ItemStackWrapper forceWrap(@Nullable ItemStack itemStack) { public static ItemStackWrapper forceWrap(@Nonnull ItemStack itemStack) {
if (itemStack == null) { Validate.notNull(itemStack, "The ItemStack cannot be null!");
return null;
}
return new ItemStackWrapper(itemStack); return new ItemStackWrapper(itemStack);
} }
@ -143,15 +140,13 @@ public final class ItemStackWrapper extends ItemStack {
* is already an {@link ItemStackWrapper} * is already an {@link ItemStackWrapper}
* *
* @param itemStack The {@link ItemStack} to wrap * @param itemStack The {@link ItemStack} to wrap
* @return Returns <code>null</code> only if the passed ItemStack is <code>null</code>. * @return Returns an {@link ItemStackWrapper} of the passed {@link ItemStack}
* Otherwise: An {@link ItemStackWrapper} of the passed {@link ItemStack}
* @see #forceWrap(ItemStack) * @see #forceWrap(ItemStack)
*/ */
@Nullable @Nonnull
public static ItemStackWrapper wrap(@Nullable ItemStack itemStack) { public static ItemStackWrapper wrap(@Nonnull ItemStack itemStack) {
if (itemStack == null) { Validate.notNull(itemStack, "The ItemStack cannot be null!");
return null; if (itemStack instanceof ItemStackWrapper) {
} else if (itemStack instanceof ItemStackWrapper) {
return (ItemStackWrapper) itemStack; return (ItemStackWrapper) itemStack;
} }
return new ItemStackWrapper(itemStack); return new ItemStackWrapper(itemStack);