-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Validate checks #3589
Replace Validate checks #3589
Conversation
Not sure about how you would like to replace |
Validate.noNullElements(handlers, "You cannot add any 'null' ItemHandler!"); | ||
Preconditions.checkArgument(handlers != null && handlers.length > 0, "You cannot add zero handlers..."); | ||
for (ItemHandler handler : handlers) { | ||
Preconditions.checkArgument(handler != null, "You cannot add any 'null' ItemHandler!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should definitely be a util method.
I don't think it warrants needing to be in dough so I'd just add it under our utils package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really find Preconditions.checkNotNull
better semantic wise but it's a shame that it throws an NPE...
I was really hoping we could avoid writing our own util for it, but it really seems like Preconditions
doesn't cover our use cases too well...
Perhaps a Validate
class should be added to dough-common
then... or Slimefun's util package.
What do the others think?
I would say push this to Dough so plugins that use Dough only and not Slimefun can make use of it aswell. |
I'll open a new pr when Slimefun/dough#184 is merged. |
Description
As #3586 said, replace all Validate checks with Precondition.
Proposed changes
Validate.notNull(Object, String)
withPreconditions.checkArgument(Object, String)
. (Changing toPreconditions.checkNotNull
will throwNullPointerException
)Related Issues (if applicable)
Resolves #3586
Checklist
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null values