All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.craftsman.JdkMissingConverter Maven / Gradle / Ivy

Go to download

A library that provides the missing Java 8 type mappers for the Dozer Java Bean Mapper.

There is a newer version: 1.0.6
Show newest version
package io.craftsman;

import io.craftsman.creator.CreatorFactory;
import org.dozer.CustomConverter;

import java.util.Locale;

public class JdkMissingConverter implements CustomConverter {

    private CreatorFactory creatorFactory = new CreatorFactory();

    @Override
    public Object convert(Object destination, Object source, Class destinationClass, Class sourceClass) {

        if (destinationClass == null || sourceClass == null) {
            return destination;
        }

        if (source == null) {
            destination = null;
        } else if (destinationClass.isAssignableFrom(Locale.class) && sourceClass.isAssignableFrom(Locale.class)) {
            destination = creatorFactory.createLocaleCreator().create(source);
        }

        return destination;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy