Search in sources :

Example 6 with ConvertiblePair

use of org.springframework.core.convert.converter.GenericConverter.ConvertiblePair in project spring-data-commons by spring-projects.

the class CustomConversions method register.

/**
 * Registers the given {@link ConvertiblePair} as reading or writing pair depending on the type sides being basic
 * Mongo types.
 *
 * @param converterRegistration
 */
private void register(ConverterRegistration converterRegistration) {
    Assert.notNull(converterRegistration, "Converter registration must not be null!");
    ConvertiblePair pair = converterRegistration.getConvertiblePair();
    if (converterRegistration.isReading()) {
        readingPairs.add(pair);
        if (LOG.isWarnEnabled() && !converterRegistration.isSimpleSourceType()) {
            LOG.warn(String.format(READ_CONVERTER_NOT_SIMPLE, pair.getSourceType(), pair.getTargetType()));
        }
    }
    if (converterRegistration.isWriting()) {
        writingPairs.add(pair);
        customSimpleTypes.add(pair.getSourceType());
        if (LOG.isWarnEnabled() && !converterRegistration.isSimpleTargetType()) {
            LOG.warn(String.format(WRITE_CONVERTER_NOT_SIMPLE, pair.getSourceType(), pair.getTargetType()));
        }
    }
}
Also used : ConvertiblePair(org.springframework.core.convert.converter.GenericConverter.ConvertiblePair)

Aggregations

ConvertiblePair (org.springframework.core.convert.converter.GenericConverter.ConvertiblePair)6 GenericConverter (org.springframework.core.convert.converter.GenericConverter)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Function (java.util.function.Function)1 AccessLevel (lombok.AccessLevel)1 Getter (lombok.Getter)1 NonNull (lombok.NonNull)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Value (lombok.Value)1 Slf4j (lombok.extern.slf4j.Slf4j)1