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

us.codecraft.webmagic.model.formatter.ObjectFormatters Maven / Gradle / Ivy

The newest version!
package us.codecraft.webmagic.model.formatter;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author [email protected]
 * @since 0.3.2
 */
public class ObjectFormatters {

    private static Map> formatterMap = new ConcurrentHashMap>();

    static {
        for (Class basicTypeFormatter : BasicTypeFormatter.basicTypeFormatters) {
            put(basicTypeFormatter);
        }
        put(DateFormatter.class);
    }

    public static void put(Class objectFormatter) {
        try {
            formatterMap.put(objectFormatter.newInstance().clazz(), objectFormatter);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }

    public static Class get(Class clazz){
        return formatterMap.get(clazz);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy