@Nullable public static BsonNumber<?> getNumeric(BsonDocument doc, NumberField<?> field, BsonNumber defaultValue) throws TypesMismatchException { return getNumeric(doc, field.getFieldName(), defaultValue); }
@Nonnull public static BsonNumber<?> getNumeric(BsonDocument doc, NumberField<?> field) throws TypesMismatchException, NoSuchKeyException { return BsonReaderTool.getNumeric(doc, field.getFieldName()); }
@Nonnull public static BsonNumber<?> getNumeric(BsonDocument doc, String fieldId) throws TypesMismatchException, NoSuchKeyException { return getNumeric(getEntry(doc, fieldId), fieldId); }
@Nullable public static BsonNumber<?> getNumeric(BsonDocument doc, String fieldId, BsonNumber defaultValue) throws TypesMismatchException { Entry<?> entry = doc.getEntry(fieldId); if (entry == null) { return defaultValue; } return getNumeric(entry, fieldId); }
@Nonnull public static OpTime fromBson(BsonDocument doc) throws TypesMismatchException, NoSuchKeyException { BsonTimestamp ts = BsonReaderTool.getTimestamp(doc, TIMESTAMP_FIELD); //TODO(gortiz): check precision lost long term = BsonReaderTool.getNumeric(doc, TERM_FIELD) .getValue() .longValue(); return new OpTime(ts, term); }
@Nonnull public static OpTime fromOplogEntry(BsonDocument doc) throws TypesMismatchException, NoSuchKeyException { BsonTimestamp ts = BsonReaderTool.getTimestamp(doc, TIMESTAMP_FIELD); //TODO(gortiz): check precision lost long term = BsonReaderTool.getNumeric(doc, TERM_FIELD, UNINITIALIZED_TERM_BSON) .getValue() .longValue(); return new OpTime(ts, term); }
timeout = BsonReaderTool.getNumeric(doc, "timeout").intValue(); } catch (NoSuchKeyException ex) { timeout = 0;