Skip to content

Commit

Permalink
Added functionality to add customConverters. (#1886)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
bipoool authored Jan 12, 2024
1 parent 6e17572 commit 56a750d
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(
Expand All @@ -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<Object> converters) {
// NO_OP
}

public static Map<Class<? extends Annotation>, Class<?>> annotationToConverterMap() {
Map<Class<? extends Annotation>, Class<?>> map = new HashMap();
map.put(Encrypted.class, CryptoConverter.class);
Expand Down

0 comments on commit 56a750d

Please sign in to comment.