private int compareProduceTypes(OperationResourceInfo oper1, OperationResourceInfo oper2, final List<MediaType> acceptTypes) {
        // getting matched produce type for both handlers.
        // this is required if a method can produce multiple types.
        List<MediaType> op1Matched = JAXRSUtils.intersectMimeTypes(acceptTypes, oper1.getProduceTypes(), true);
        List<MediaType> op2Matched = JAXRSUtils.intersectMimeTypes(acceptTypes, oper2.getProduceTypes(), true);

        // calculate the max priority for both handlers
        int oper1Priority = op1Matched
                .stream()
                .mapToInt(PRIORITIZED_MEDIA_LIST::indexOf)
                .max()
                .getAsInt();
        int oper2Priority = op2Matched
                .stream()
                .mapToInt(PRIORITIZED_MEDIA_LIST::indexOf)
                .max()
                .getAsInt();

        // final calculation
        return oper1Priority == oper2Priority ? 0 : (oper1Priority > oper2Priority ? -1 : 1);
    }
Compares the method to handle.
Gets the maximum priority match for both handlers,
and chooses the handler that has the maximum priority match.

@param oper1       the first resource handler info.
@param oper2       the second resource handler info.
@param acceptTypes the list acceptable response mime type, for the message.
@return value based on chosen handler. Returns -1 if first, 1 if second and 0 if no decision.
tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/ProduceTypeResourceComparator.java