bson/src/main/org/bson/AbstractBsonWriter.java
protected boolean checkState(final State[] validStates) {
        for (final State cur : validStates) {
            if (cur == getState()) {
                return true;
            }
        }
        return false;
    }
protected boolean checkState(final State[] validStates) {
        for (final State cur : validStates) {
            if (cur == getState()) {
                return true;
            }
        }
        return false;
    }
Checks if this writer's current state is in the list of given states.

@param validStates an array of {@code State}s to compare this writer's state to.
@return true if this writer's state is in the given list.