sdcf4j icon indicating copy to clipboard operation
sdcf4j copied to clipboard

Support @Nonnull on parameters of command handler methods

Open Vampire opened this issue 8 years ago • 2 comments

Check for jsr305 annotation @Nonnull on a parameter and if the parameter is annotated with it, but you would give null or an empty Optional to it, either throw an exception or make a debug log statement and just do not call the handler

Vampire avatar Dec 16 '17 23:12 Vampire

Can this not be validated on the user side? A simple Objects.requireNonNull() call would suffice.

darichey avatar Dec 27 '17 21:12 darichey

Sure it could. This is about convenience. The lib could do it for you, so it is simpler to use the simple command framework. Depending on whether an exception is thrown or just a debug statement and the handler not called, you can easily define with this conditions for the command like you can do now with Command.channelMessages and Command.privateMessages, just that you can do it for all the potential parameters.

Vampire avatar Dec 28 '17 02:12 Vampire