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

net.minidev.asm.BeansAccessConfig Maven / Gradle / Ivy

package net.minidev.asm;

import java.util.HashMap;
import java.util.LinkedHashSet;

/**
 * Beans Access Config
 */
public class BeansAccessConfig {
	/**
	 * default constructor
	 */
	public BeansAccessConfig() {
		super();
	}
	/**
	 * Field type convertor for all classes
	 * 
	 * Convertor classes should contains mapping method Prototyped as:
	 * 
	 * public static DestinationType Method(Object data);
	 * 
	 * @see DefaultConverter
	 */
	//static protected LinkedHashSet> globalMapper = new LinkedHashSet>();

	/**
	 * Field type convertor for custom Class
	 * 
	 * Convertor classes should contains mapping method Prototyped as:
	 * 
	 * public static DestinationType Method(Object data);
	 * 
	 * @see DefaultConverter
	 */
	static protected HashMap, LinkedHashSet>> classMapper = new HashMap, LinkedHashSet>>();

	/**
	 * FiledName remapper for a specific class or interface
	 */
	static protected HashMap, HashMap> classFiledNameMapper = new HashMap, HashMap>();

	static {
		addTypeMapper(Object.class, DefaultConverter.class);
		addTypeMapper(Object.class, ConvertDate.class);
	}

//	/**
//	 * Field type convertor for all classes
//	 * 
//	 * Convertor classes should contains mapping method Prototyped as:
//	 * 
//	 * public static DestinationType Method(Object data);
//	 * 
//	 * @see DefaultConverter
//	 */
//	public static void addGlobalTypeMapper(Class mapper) {
//		synchronized (globalMapper) {
//			globalMapper.add(mapper);
//		}
//	}

	/**
	 * Field type convertor for all classes
	 * 
	 * Convertor classes should contains mapping method Prototyped as:
	 * 
	 * public static DestinationType Method(Object data);
	 * 
	 * @see DefaultConverter
	 * 
	 * @param clz class
	 * @param mapper mapper
	 */
	public static void addTypeMapper(Class clz, Class mapper) {
		synchronized (classMapper) {
			LinkedHashSet> h = classMapper.get(clz);
			if (h == null) {
				h = new LinkedHashSet>();
				classMapper.put(clz, h);
			}
			
			h.add(mapper);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy