private boolean getReturnKey(BsonValue<?> value) { switch (value.getType()) { case BOOLEAN: return ((BsonBoolean) value).getPrimitiveValue(); case UNDEFINED: case NULL: return false; default: return true; } }
public default long toRawData() { return getSecondsSinceEpoch() << 32 + getOrdinal(); } }
private long getMaxScan(BsonValue<?> value) { switch (value.getType()) { case INT32: return ((BsonInt32) value).intValue(); case INT64: return ((BsonInt64) value).longValue(); case DOUBLE: return Math.round(((BsonDouble) value).doubleValue()); default: return -1; } }
public static int getInteger(Entry<?> entry, String fieldId) throws TypesMismatchException { BsonValue<?> object = entry.getValue(); if (!object.isInt32()) { String foundType = toStringBsonType(object.getType()); throw new TypesMismatchException( fieldId, "integer", object.getType(), "Expected integer type for field " + fieldId + ". Found" + foundType ); } return object.asInt32().intValue(); }
public static double getDouble(Entry<?> entry, String fieldId) throws TypesMismatchException { BsonValue object = entry.getValue(); if (!object.isDouble()) { String foundType = toStringBsonType(object.getType()); throw new TypesMismatchException( fieldId, "integer", object.getType(), "Expected double type for field " + fieldId + ". Found" + foundType ); } return object.asDouble().doubleValue(); }
@Nonnull public static Instant getInstant(Entry<?> entry, String fieldId) throws TypesMismatchException { BsonValue<?> value = entry.getValue(); if (!value.isDateTime()) { throw new TypesMismatchException( fieldId, "date", value.getType(), "Expected date type for field " + fieldId + ". Found" + value ); } return value.asDateTime().getValue(); }
public static BsonTimestamp getTimestamp(BsonDocument doc, String fieldId) throws NoSuchKeyException, TypesMismatchException { Entry<?> entry = doc.getEntry(fieldId); if (entry == null) { throw new NoSuchKeyException(fieldId); } BsonValue<?> value = entry.getValue(); if (!value.isTimestamp()) { throw new TypesMismatchException(fieldId, "timestamp", value.getType()); } return value.asTimestamp(); }
@Override public String getValue() { return wrapped.getValue(); } }
@Override public KvValue<?> apply(BsonValue<?> bsonValue) { return bsonValue.accept(this, null); }
@Override public <R, A> R accept(BsonValueVisitor<R, A> visitor, A arg) { return visitor.visit(this, arg); }
private boolean getSnapshot(BsonValue<?> value) { switch (value.getType()) { case BOOLEAN: return ((BsonBoolean) value).getPrimitiveValue(); case UNDEFINED: case NULL: return false; default: return true; } }
@Override public <R, A> R accept(BsonValueVisitor<R, A> visitor, A arg) { return visitor.visit(this, arg); }
private boolean getShowDiskLoc(BsonValue<?> value) { switch (value.getType()) { case BOOLEAN: return ((BsonBoolean) value).getPrimitiveValue(); case UNDEFINED: case NULL: return false; default: return true; } }
@Override public <R, A> R accept(BsonValueVisitor<R, A> visitor, A arg) { return visitor.visit(this, arg); }
@Override public <R, A> R accept(BsonValueVisitor<R, A> visitor, A arg) { return visitor.visit(this, arg); }
@Override public <R, A> R accept(BsonValueVisitor<R, A> visitor, A arg) { return visitor.visit(this, arg); }
@Override public <R, A> R accept(BsonValueVisitor<R, A> visitor, A arg) { return visitor.visit(this, arg); }