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

com.alon.spring.crud.repository.specification.converter.ConverterResolver Maven / Gradle / Ivy

Go to download

Projeto base para criação de serviços e recusos de CRUD com Spring Data JPA.

There is a newer version: 3.0.0
Show newest version
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.alon.spring.crud.repository.specification.converter;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author paulo
 */
public abstract class ConverterResolver {
    
    private static final Map, DecoderConverter> CONVERTERS = new HashMap<>();
    
    static {
        CONVERTERS.put(String.class, DefaultConverter.getInstance());
        CONVERTERS.put(Integer.class, IntegerConverter.getInstance());
        CONVERTERS.put(Long.class, LongConverter.getInstance());
        CONVERTERS.put(Float.class, FloatConverter.getInstance());
        CONVERTERS.put(Double.class, DoubleConverter.getInstance());
        CONVERTERS.put(BigDecimal.class, BigDecimalConverter.getInstance());
        CONVERTERS.put(Boolean.class, BooleanConverter.getInstance());
        CONVERTERS.put(Date.class, DateTimeConverter.getInstance());
    }
    
    public static  DecoderConverter resolve(Class clazz) {
        DecoderConverter converter = CONVERTERS.get(clazz);
        
        if (converter == null)
            converter = DefaultConverter.getInstance();
        
        return converter;
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy