package org.axonframework.queryhandling;

import org.axonframework.messaging.MessageHandler;
import org.axonframework.queryhandling.responsetypes.ResponseType;

import java.lang.reflect.Type;

/**
 * Encapsulates the identifying fields of a Query Handler when one is subscribed to the
 * {@link org.axonframework.queryhandling.QueryBus}. As such contains the response type of the query handler and the
 * complete handler itself.
 * The first is typically used by the QueryBus to select the right query handler when a query comes in.
 * The latter is used to perform the actual query.
 *
 * @param <R> the type of response this query subscription contains
 */
class QuerySubscription<R> {

    private final Type responseType;
    private final MessageHandler<? super QueryMessage<?, R>> queryHandler;

    QuerySubscription(Type responseType, MessageHandler<? super QueryMessage<?, R>> queryHandler) {
        this.responseType = responseType;
        this.queryHandler = queryHandler;
    }

    public Type getResponseType() {
        return responseType;
    }

    public boolean canHandle(ResponseType queryResponseType) {
        return queryResponseType.matches(responseType);
    }

    public MessageHandler<? super QueryMessage<?, R>> getQueryHandler() {
        return queryHandler;
    }
}

@@ -184,16 +184,42 @@
 ct.Type;
+%0Aimport java.util.Objects;
 %0A%0A/**%0A *
@@ -830,494 +830,2482 @@
     
-QuerySubscription(Type responseType, MessageHandler%3C? super QueryMessage%3C?, R%3E%3E queryHandler) %7B%0A        this.responseType = responseType;%0A        this.queryHandler = queryHandler;%0A    %7D%0A%0A    public Type getResponseType() %7B%0A        return responseType;%0A    %7D%0A%0A    public boolean canHandle(ResponseType queryResponseType) %7B%0A        return queryResponseType.matches(responseType);%0A    %7D%0A%0A    public MessageHandler%3C? super QueryMessage%3C?, R%3E%3E getQueryHandler() %7B%0A        return queryHandler
+/**%0A     * Instantiate a %7B@link QuerySubscription%7D with a specific %7B@code responseType%7D and %7B@code queryHandler%7D.%0A     *%0A     * @param responseType a %7B@link java.lang.reflect.Type%7D as the response type of this subscription%0A     * @param queryHandler the subscribed %7B@link org.axonframework.messaging.MessageHandler%7D%0A     */%0A    QuerySubscription(Type responseType, MessageHandler%3C? super QueryMessage%3C?, R%3E%3E queryHandler) %7B%0A        this.responseType = responseType;%0A        this.queryHandler = queryHandler;%0A    %7D%0A%0A    /**%0A     * Retrieve the response type of this subscription as a %7B@link java.lang.reflect.Type%7D.%0A     *%0A     * @return the response type as a %7B@link java.lang.reflect.Type%7D tied to this subscription%0A     */%0A    public Type getResponseType() %7B%0A        return responseType;%0A    %7D%0A%0A    /**%0A     * Check if this %7B@link QuerySubscription%7D can handle the given %7B@code queryResponseType%7D, by calling the%0A     * %7B@link org.axonframework.queryhandling.responsetypes.ResponseType#matches(Type)%7D function on it and providing the%0A     * set %7B@code responseType%7D of this subscription.%0A     *%0A     * @param queryResponseType a %7B@link org.axonframework.queryhandling.responsetypes.ResponseType%7D to match this%0A     *                          subscriptions it's %7B@code responseType%7D against%0A     * @return true of the given %7B@code queryResponseType%7D its%0A     * %7B@link org.axonframework.queryhandling.responsetypes.ResponseType#matches(Type)%7D returns true, false if otherwise%0A     */%0A    public boolean canHandle(ResponseType queryResponseType) %7B%0A        return queryResponseType.matches(responseType);%0A    %7D%0A%0A    /**%0A     * Retrieve the query handler of this subscription as a %7B@link org.axonframework.messaging.MessageHandler%7D.%0A     *%0A     * @return the %7B@link org.axonframework.messaging.MessageHandler%7D tied to this subscription%0A     */%0A    public MessageHandler%3C? super QueryMessage%3C?, R%3E%3E getQueryHandler() %7B%0A        return queryHandler;%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return Objects.hash(responseType, queryHandler);%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (this == obj) %7B%0A            return true;%0A        %7D%0A        if (obj == null %7C%7C getClass() != obj.getClass()) %7B%0A            return false;%0A        %7D%0A        final QuerySubscription other = (QuerySubscription) obj;%0A        return Objects.equals(this.responseType, other.responseType)%0A                && Objects.equals(this.queryHandler, other.queryHandler)
 ;%0A  

Update the QuerySubscription