@Override public String toString() { BsonDocumentBuilder bson = toDescriptiveBson(); return bson.build().toString(); } }
public BsonDocumentBuilder append(DocField field, BsonDocumentBuilder value) { Preconditions.checkState(!built); if (value == null) { return appendNull(field); } map.put(field.getFieldName(), value.build()); return this; }
@Override public BsonDocument marshall() { BsonDocumentBuilder builder = new BsonDocumentBuilder(); marshall(builder); return builder.build(); }
public BsonDocument toBson() { return new BsonDocumentBuilder(2) .append(TIMESTAMP_FIELD, timestamp) .append(TERM_FIELD, term) .build(); }
@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(); }
@Override public BsonDocument getBson() { if (bson == null) { try { bson = command.marshallResult(commandReply.get()); } catch (MarshalException ex) { LOGGER.debug("Impossible to marshall a reply for " + command.getCommandName() + " command", ex); bson = new BsonDocumentBuilder(2) .appendUnsafe("errorOn", DefaultBsonValues.newString("marshallable respose")) .appendUnsafe("command", DefaultBsonValues.newString(command.getCommandName())) .build(); } } return bson; }
@Material public BsonDocument toDocument() { BsonDocumentBuilder builder = new BsonDocumentBuilder(3); if (getWType().equals(WType.TEXT)) { builder.append(W_TEXT_FIELD, getWString()); } else { builder.append(W_INT_FIELD, getWInt()); } switch (getSyncMode()) { case FSYNC: builder.append(FSYNC_FIELD, true); break; case JOURNAL: builder.append(JOURNAL_FIELD, true); break; default: } builder.append(TIMEOUT_FIELD, getTimeout()); return builder.build(); }