Converter

Registering a Spring Converter

The ArangoConfiguration provides a convenient way to register Spring Converter by implementing the method customConverters().

Examples

@Configuration
public class MyConfiguration implements ArangoConfiguration {

  @Override
  protected Collection<Converter<?, ?>> customConverters() {
    return Arrays.asList(new MyConverter());
  }

}

Implementing a Spring Converter

A Converter is used for reading if the source type is of type JsonNode or DBDocumentEntity.

A Converter is used for writing if the target type is of type JsonNode, DBDocumentEntity, BigInteger, BigDecimal, java.sql.Date, java.sql.Timestamp, Instant, LocalDate, LocalDateTime, OffsetDateTime, ZonedDateTime, Boolean, Short, Integer, Byte, Float, Double, Character, String, Date, Class, Enum, boolean[], long[], short[], int[], byte[], float[], double[] or char[].

Examples

public class MyConverter implements Converter<MyObject, JsonNode> {

  @Override
  public JsonNode convert(final MyObject source) {
    ObjectNode on = JsonNodeFactory.instance.objectNode();
    // map fields of MyObject to builder
    // on.put("key", "value");
    // ...  
    return on;
  }

}