public RecordState validateTransition(RecordState newState) throws IllegalStateException {
            Objects.requireNonNull(newState, "newState cannot be null");
            if (this == newState) {
                throw new IllegalStateException("The state transition is invalid as the new state is"
                    + "the same as the current state");
            }

            if (this == ACKNOWLEDGED || this == ARCHIVED) {
                throw new IllegalStateException("The state transition is invalid from the current state: " + this);
            }

            if (this == AVAILABLE && newState != ACQUIRED) {
                throw new IllegalStateException("The state can only be transitioned to ACQUIRED from AVAILABLE");
            }

            // Either the transition is from Available -> Acquired or from Acquired -> Available/
            // Acknowledged/Archived.
            return newState;
        }
Validates that the <code>newState</code> is one of the valid transition from the current
{@code RecordState}.

@param newState State into which requesting to transition; must be non-<code>null</code>

@return {@code RecordState} <code>newState</code> if validation succeeds. Returning
        <code>newState</code> helps state assignment chaining.

@throws IllegalStateException if the state transition validation fails.
core/src/main/java/kafka/server/share/SharePartition.java