core-java icon indicating copy to clipboard operation
core-java copied to clipboard

Misleading Javadoc for `Policy.whenever()`

Open alexander-yevsyukov opened this issue 2 years ago • 1 comments

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.

alexander-yevsyukov avatar Jul 25 '23 22:07 alexander-yevsyukov

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."

alexander-yevsyukov avatar Jul 25 '23 22:07 alexander-yevsyukov