Java Code Examples for org.bson.BsonType#OBJECT_ID
The following examples show how to use
org.bson.BsonType#OBJECT_ID .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJsonCodec.java From vertx-mongo-client with Apache License 2.0 | 6 votes |
protected BsonType getBsonType(Object value) { if (value == null) { return BsonType.NULL; } else if (value instanceof Boolean) { return BsonType.BOOLEAN; } else if (value instanceof Double) { return BsonType.DOUBLE; } else if (value instanceof Integer) { return BsonType.INT32; } else if (value instanceof Long) { return BsonType.INT64; } else if (value instanceof String) { return BsonType.STRING; } else if (isObjectIdInstance(value)) { return BsonType.OBJECT_ID; } else if (isObjectInstance(value)) { return BsonType.DOCUMENT; } else if (isArrayInstance(value)) { return BsonType.ARRAY; } else { return null; } }
Example 2
Source File: StringCodecExt.java From xian with Apache License 2.0 | 5 votes |
@Override public String decode(BsonReader reader, DecoderContext decoderContext) { if (reader.getCurrentBsonType() == BsonType.OBJECT_ID) { return reader.readObjectId().toString(); } return super.decode(reader, decoderContext); }
Example 3
Source File: BsonReaderWrapper.java From core-ng-project with Apache License 2.0 | 5 votes |
public ObjectId readObjectId(String field) { BsonType currentType = reader.getCurrentBsonType(); if (currentType == BsonType.NULL) { reader.readNull(); return null; } else if (currentType == BsonType.OBJECT_ID) { return reader.readObjectId(); } else { logger.warn("unexpected field type, field={}, type={}", field, currentType); reader.skipValue(); return null; } }