*
* @return null
* if for some reason it fails to create an optimized version.
*/
public static final TransducedAccessor get(RuntimePropertyInfo prop) {
Accessor acc = prop.getAccessor();
// consider using an optimized TransducedAccessor implementations.
Class opt=null;
TypeInfo<Type,Class> parent = prop.parent();
if(!(parent instanceof RuntimeClassInfo))
return null;
Class dc = ((RuntimeClassInfo)parent).getClazz();
String newClassName = toVMClassName(dc)+"_JaxbXducedAccessor_"+prop.getName();
if(acc instanceof Accessor.FieldReflection) {
// TODO: we also need to make sure that the default xducer is used.
Accessor.FieldReflection racc = (Accessor.FieldReflection) acc;
Field field = racc.f;
int mods = field.getModifiers();
if(Modifier.isPrivate(mods) || Modifier.isFinal(mods))
// we can't access private fields.
// TODO: think about how to improve this case
return null;
Class<?> t = field.getType();
if(t.isPrimitive())
opt = AccessorInjector.prepare( dc,
fieldTemplateName+suffixMap.get(t),
newClassName,
toVMClassName(Bean.class),
toVMClassName(dc),
"f_"+t.getName(),
field.getName() );
}
if(acc.getClass()==Accessor.GetterSetterReflection.class) {
Accessor.GetterSetterReflection gacc = (Accessor.GetterSetterReflection) acc;
if(gacc.getter==null || gacc.setter==null)
return null; // incomplete