core-java
core-java copied to clipboard
Misleading Javadoc for `Policy.whenever()`
Now it says:
Handles an event and produces some number of events in response.
The signature is:
@ContractFor(handler = React::class)
protected abstract fun whenever(event: E): Iterable<Message>
Logically, we can emit not only events, but commands too. It would be also good to bind it on the level of the method signature.
There's also a small diagnostic issue in this class. The method checkReceptors() produces the following error:
"Policy `${javaClass.name}` handles too many events: [${classes.joinToString()}]."
This raises a question: “How many is too many?” It should be something like:
"The policy `${javaClass.name}` should react on only one event. Now it handles too many ({$classes.size}): [${classes.joinToString()}]. Please use only `whenever()` method for producing outcoming messages."