@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void encode(final BsonWriter writer, final BsonValue value, final EncoderContext encoderContext) { Codec codec = codecRegistry.get(value.getClass()); encoderContext.encodeWithChildContext(codec, writer, value); }
@SuppressWarnings({"unchecked", "rawtypes"}) private void writeValue(final BsonWriter writer, final EncoderContext encoderContext, final BsonValue value) { Codec codec = codecRegistry.get(value.getClass()); encoderContext.encodeWithChildContext(codec, writer, value); }
@SuppressWarnings({"unchecked", "rawtypes"}) private void writeValue(final BsonWriter writer, final EncoderContext encoderContext, final Object value) { if (value == null) { writer.writeNull(); } else { Codec codec = registry.get(value.getClass()); encoderContext.encodeWithChildContext(codec, writer, value); } }
@SuppressWarnings({"unchecked", "rawtypes"}) private void writeValue(final BsonWriter writer, final EncoderContext encoderContext, final Object value) { if (value == null) { writer.writeNull(); } else { Codec codec = registry.get(value.getClass()); encoderContext.encodeWithChildContext(codec, writer, value); } } }
@Override @SuppressWarnings({"unchecked", "rawtypes"}) public void encode(final BsonWriter writer, final BsonArray array, final EncoderContext encoderContext) { writer.writeStartArray(); for (BsonValue value : array) { Codec codec = codecRegistry.get(value.getClass()); encoderContext.encodeWithChildContext(codec, writer, value); } writer.writeEndArray(); }
@SuppressWarnings({"unchecked", "rawtypes"}) static void encodeCoordinateReferenceSystem(final BsonWriter writer, final Geometry geometry, final EncoderContext encoderContext, final CodecRegistry registry) { CoordinateReferenceSystem coordinateReferenceSystem = geometry.getCoordinateReferenceSystem(); if (coordinateReferenceSystem != null) { writer.writeName("crs"); Codec codec = registry.get(coordinateReferenceSystem.getClass()); encoderContext.encodeWithChildContext(codec, writer, coordinateReferenceSystem); } }
@SuppressWarnings({"unchecked", "rawtypes"}) private void writeValue(final BsonWriter writer, final EncoderContext encoderContext, final Object value) { if (value == null) { writer.writeNull(); } else if (value instanceof Iterable) { writeIterable(writer, (Iterable<Object>) value, encoderContext.getChildContext()); } else if (value instanceof Map) { writeMap(writer, (Map<String, Object>) value, encoderContext.getChildContext()); } else { Codec codec = registry.get(value.getClass()); encoderContext.encodeWithChildContext(codec, writer, value); } }
private <S> void encodeValue(final BsonWriter writer, final EncoderContext encoderContext, final PropertyModel<S> propertyModel, final S propertyValue) { if (propertyModel.shouldSerialize(propertyValue)) { writer.writeName(propertyModel.getReadName()); if (propertyValue == null) { writer.writeNull(); } else { try { encoderContext.encodeWithChildContext(propertyModel.getCachedCodec(), writer, propertyValue); } catch (CodecConfigurationException e) { throw new CodecConfigurationException(format("Failed to encode '%s'. Encoding '%s' errored with: %s", classModel.getName(), propertyModel.getReadName(), e.getMessage()), e); } } } }
Codec dateCodec = codecRegistry.get(LocalDate.class); writer.writeName("startDate"); ec.encodeWithChildContext(dateCodec, writer, t.getStartDate()); writer.writeName("endDate"); ec.encodeWithChildContext(dateCodec, writer, t.getEndDate()); writer.writeName("blockLength"); writer.writeInt32(t.getBlockLength()); for (Ra ra : t.getRasOnDuty()) { Codec raCodec = codecRegistry.get(Ra.class); ec.encodeWithChildContext(raCodec, writer, ra);
@SuppressWarnings({"unchecked", "rawtypes"}) static void encodeCoordinateReferenceSystem(final BsonWriter writer, final Geometry geometry, final EncoderContext encoderContext, final CodecRegistry registry) { CoordinateReferenceSystem coordinateReferenceSystem = geometry.getCoordinateReferenceSystem(); if (coordinateReferenceSystem != null) { writer.writeName("crs"); Codec codec = registry.get(coordinateReferenceSystem.getClass()); encoderContext.encodeWithChildContext(codec, writer, coordinateReferenceSystem); } }
for (Document document : user.getHistory()) { Codec<Document> documentCodec = codecRegistry.get(Document.class); encoderContext.encodeWithChildContext(documentCodec, writer, document);