package poussecafe.environment;


public class MessageListeners {

    public void include(MessageListener listener) {
        MessageListenerType priority = listener.priority();
        if(priority == MessageListenerType.FACTORY) {
            if(factoryListener == null) {
                factoryListener = listener;
            } else {
                throw new IllegalArgumentException("There is already a factory listener for message " + listener.messageClass().getName());
            }
        } else if(priority == MessageListenerType.AGGREGATE) {
            if(aggregateListener == null) {
                aggregateListener = listener;
            } else {
                throw new IllegalArgumentException("There is already a aggregate listener for message " + listener.messageClass().getName());
            }
        } else if(priority == MessageListenerType.REPOSITORY) {
            if(repositoryListener == null) {
                repositoryListener = listener;
            } else {
                throw new IllegalArgumentException("There is already a repository listener for message " + listener.messageClass().getName());
            }
        } else {
            throw new UnsupportedOperationException("Unsupported priority " + priority);
        }
    }

    private MessageListener factoryListener;

    private MessageListener aggregateListener;

    private MessageListener repositoryListener;
}

@@ -412,32 +412,87 @@
 factory listener
+ in %22 + listener.aggregateRootClass().orElseThrow() + %22
  for message %22 +
@@ -520,32 +520,32 @@
 s().getName());%0A
-
             %7D%0A  
@@ -786,16 +786,17 @@
 lready a
+n
  aggrega
@@ -798,32 +798,87 @@
 gregate listener
+ in %22 + listener.aggregateRootClass().orElseThrow() + %22
  for message %22 +
@@ -1097,32 +1097,32 @@
        %7D else %7B%0A
-
                 
@@ -1195,16 +1195,71 @@
 listener
+ in %22 + listener.aggregateRootClass().orElseThrow() + %22
  for mes

Improve error message for message listeners consistency rules.