From 56a750d1aba5d9c9e52986270ce1f6c8bf98da20 Mon Sep 17 00:00:00 2001 From: Vipul Gupta <86769501+bipoool@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:58:57 +0530 Subject: [PATCH] Added functionality to add customConverters. (#1886) * Added functionality to add customConverters. Added functionality to register custom converters in the list + cleaned up the code a little and. * Review chages. Function name changed and restored to old implementation * Documentation Changes. --- .../couchbase/config/AbstractCouchbaseConfiguration.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java b/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java index c97f3d8a3..4db4a2936 100644 --- a/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java +++ b/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java @@ -428,6 +428,7 @@ public CustomConversions customConversions() { * and {@link #couchbaseMappingContext(CustomConversions)}. * * @param cryptoManager + * @param objectMapper * @return must not be {@literal null}. */ public CustomConversions customConversions(CryptoManager cryptoManager, ObjectMapper objectMapper) { @@ -437,6 +438,7 @@ public CustomConversions customConversions(CryptoManager cryptoManager, ObjectMa newConverters.add(new IntegerToEnumConverterFactory(getObjectMapper())); newConverters.add(new StringToEnumConverterFactory(getObjectMapper())); newConverters.add(new BooleanToEnumConverterFactory(getObjectMapper())); + additionalConverters(newConverters); CustomConversions customConversions = CouchbaseCustomConversions.create(configurationAdapter -> { SimplePropertyValueConversions valueConversions = new SimplePropertyValueConversions(); valueConversions.setConverterFactory( @@ -449,6 +451,13 @@ public CustomConversions customConversions(CryptoManager cryptoManager, ObjectMa return customConversions; } + /** + * This should be overridden in order to update the {@link #customConversions(CryptoManager cryptoManager, ObjectMapper objectMapper)} List + */ + protected void additionalConverters(List converters) { + // NO_OP + } + public static Map, Class> annotationToConverterMap() { Map, Class> map = new HashMap(); map.put(Encrypted.class, CryptoConverter.class);