public static RecordState forId(byte id) {
            switch (id) {
                case 0:
                    return AVAILABLE;
                case 1:
                    return ACQUIRED;
                case 2:
                    return ACKNOWLEDGED;
                case 4:
                    return ARCHIVED;
                default:
                    throw new IllegalArgumentException("Unknown record state id: " + id);
            }
        }
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