private static JsonToken toGsonToken(BsonType type) {
    switch (type) {
    case END_OF_DOCUMENT:
      return JsonToken.END_DOCUMENT;
    case DOCUMENT:
      return JsonToken.BEGIN_OBJECT;
    case ARRAY:
      return JsonToken.BEGIN_ARRAY;
    case BOOLEAN:
      return JsonToken.BOOLEAN;
    case STRING:
    case SYMBOL:
    case OBJECT_ID:
    case BINARY:
    case REGULAR_EXPRESSION:
      return JsonToken.STRING;
    case DATE_TIME:
    case DOUBLE:
    case INT32:
    case INT64:
    case TIMESTAMP:
    case DECIMAL128:
      return JsonToken.NUMBER;
    case NULL:
    case UNDEFINED:
      return JsonToken.NULL;
    default:
      // not really sure what to do with this type
      return JsonToken.NULL;
    }
  }
In order to be able to get current location of the BSON "cursor" (document or array start/end)
enforcing clients to
provide {@link AbstractBsonReader} which exposes this information via {@code getState()}
method, instead of more generic interface {@link BsonReader}.
@param delegate
@see AbstractBsonReader#getState()
mongo/src/org/immutables/mongo/bson4gson/BsonReader.java