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

spinjar.com.minidev.asm.BeansAccessConfig Maven / Gradle / Ivy

There is a newer version: 1.23.0
Show newest version
package net.minidev.asm;

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

public class BeansAccessConfig {
	/**
	 * 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
	 */
	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