public BsonDocument toBson() { return new BsonDocumentBuilder(2) .append(TIMESTAMP_FIELD, timestamp) .append(TERM_FIELD, term) .build(); }
private void marshall(BsonDocumentBuilder builder) { builder.append(LAST_OP_FIELD, precedingOpTime); } }
@Override public BsonDocument marshall() { BsonDocumentBuilder builder = new BsonDocumentBuilder(); marshall(builder); return builder.build(); }
public BsonDocumentBuilder toDescriptiveBson() { BsonDocumentBuilder result = new BsonDocumentBuilder() .append(OPTIME_FIELD, optime) .append(HASH_FIELD, hash) .append(VERSION_FIELD, version.getNumericValue()); if (fromMigrate) { result.append(FROM_MIGRATE_FIELD, true); } return result; }
@Nonnull public static HostAndPort getHostAndPort(Entry<?> entry) throws TypesMismatchException { String string = getString(entry); return getHostAndPort(string); }
public static boolean getBoolean(BsonDocument doc, String fieldId) throws TypesMismatchException, NoSuchKeyException { return getBoolean(getEntry(doc, fieldId), fieldId); }
public static BsonTimestamp getTimestampFromDateTime(BsonDocument doc, DateTimeField field) throws NoSuchKeyException, TypesMismatchException { return getTimestampFromDateTime(getEntry(doc, field)); }
@Nonnull public static BsonDocument getDocument(BsonDocument doc, String fieldId) throws TypesMismatchException, NoSuchKeyException { return getDocument(getEntry(doc, fieldId)); }
@Nonnull public static BsonNumber<?> getNumeric(BsonDocument doc, String fieldId) throws TypesMismatchException, NoSuchKeyException { return getNumeric(getEntry(doc, fieldId), fieldId); }
@Nonnull public static Instant getInstant(BsonDocument doc, String fieldId) throws TypesMismatchException, NoSuchKeyException { return getInstant(getEntry(doc, fieldId), fieldId); }
public static boolean getBooleanOrUndefined(BsonDocument doc, String fieldId, boolean defaultValue) throws TypesMismatchException { Entry<?> entry = doc.getEntry(fieldId); if (entry == null) { return defaultValue; } return getBooleanOrUndefined(entry, fieldId, defaultValue); }
public static int getInteger(BsonDocument doc, String fieldId, int defaultValue) throws TypesMismatchException { Entry<?> entry = doc.getEntry(fieldId); if (entry == null) { return defaultValue; } return getInteger(entry, fieldId); }
public static double getDouble(BsonDocument doc, String fieldId, double defaultValue) throws TypesMismatchException { Entry<?> entry = doc.getEntry(fieldId); if (entry == null) { return defaultValue; } return getDouble(entry, fieldId); }
public static long getLong(BsonDocument doc, String fieldId, long defaultValue) throws TypesMismatchException { Entry<?> entry = doc.getEntry(fieldId); if (entry == null) { return defaultValue; } return getLong(entry, fieldId); }
public static boolean getBooleanOrNumeric(BsonDocument doc, BooleanField field, boolean defaultValue) throws TypesMismatchException { return getBooleanOrNumeric(doc, field.getFieldName(), defaultValue); }
@Override public BsonDocument marshall() { BsonDocumentBuilder builder = new BsonDocumentBuilder(); marshall(builder); builder.append(UPDATE_EXISTING_FIELD_NAME, modified != 0); if (upsertedId != null) { builder.append(UPSERTED_FIELD_NAME, upsertedId); } return builder.build(); }
public static boolean getBooleanOrUndefined(BsonDocument doc, BooleanField field, boolean defaultValue) throws TypesMismatchException { return getBooleanOrUndefined(doc, field.getFieldName(), defaultValue); }