net.minidev.asm.BeansAccessConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of accessors-smart Show documentation
Show all versions of accessors-smart Show documentation
Java reflect give poor performance on getter setter an constructor calls, accessors-smart use ASM to speed up those calls.
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
*
* @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