public ClientTelemetryState validateTransition(ClientTelemetryState newState) {
        List<ClientTelemetryState> allowableStates = VALID_NEXT_STATES.get(this);

        if (allowableStates != null && allowableStates.contains(newState)) {
            return newState;
        }

        // State transition validation failed, construct error message and throw exception.
        String validStatesClause;
        if (allowableStates != null && !allowableStates.isEmpty()) {
            validStatesClause = String.format("the valid telemetry state transitions from %s are: %s",
                this,
                allowableStates.stream().map(ClientTelemetryState::toString).collect(Collectors.joining(", ")));
        } else {
            validStatesClause = String.format("there are no valid telemetry state transitions from %s", this);
        }

        String message = String.format("Invalid telemetry state transition from %s to %s; %s",
            this,
            newState,
            validStatesClause);

        throw new IllegalStateException(message);
    }
Validates that the <code>newState</code> is one of the valid transition from the current
{@code TelemetryState}.

@param newState State into which the telemetry client requesting to transition; must be
                non-<code>null</code>
@return {@code TelemetryState} <code>newState</code> if validation succeeds. Returning
<code>newState</code> helps state assignment chaining.
@throws IllegalStateException if the state transition validation fails.
clients/src/main/java/org/apache/kafka/common/telemetry/ClientTelemetryState.java