public static int nextEpoch(int prevEpoch) {
        if (prevEpoch < 0) {
            // The next epoch after FINAL_EPOCH is always FINAL_EPOCH itself.
            return FINAL_EPOCH;
        } else if (prevEpoch == Integer.MAX_VALUE) {
            return 1;
        } else {
            return prevEpoch + 1;
        }
    }
Returns the next epoch.

@param prevEpoch The previous epoch.
@return          The next epoch.
clients/src/main/java/org/apache/kafka/common/requests/FetchMetadata.java