private static void generateAccessMethod(ClassFile cf,
Class beanType,
BeanProperty[] properties,
int methodType)
{
MethodInfo mi;
switch (methodType) {
case READ_METHOD: default: {
TypeDesc[] params = {TypeDesc.OBJECT, TypeDesc.STRING};
mi = cf.addMethod
(Modifiers.PUBLIC, "getPropertyValue", TypeDesc.OBJECT, params);
break;
}
case WRITE_METHOD: {
TypeDesc[] params = new TypeDesc[] {
TypeDesc.OBJECT, TypeDesc.STRING, TypeDesc.OBJECT
};
mi = cf.addMethod(Modifiers.PUBLIC, "setPropertyValue", null, params);
break;
}
case TRY_READ_METHOD: {
TypeDesc[] params = {TypeDesc.OBJECT, TypeDesc.STRING};
mi = cf.addMethod
(Modifiers.PUBLIC, "tryGetPropertyValue", TypeDesc.OBJECT, params);
break;
}
case TRY_WRITE_METHOD: {
TypeDesc[] params = new TypeDesc[] {
TypeDesc.OBJECT, TypeDesc.STRING, TypeDesc.OBJECT
};
mi = cf.addMethod(Modifiers.PUBLIC, "trySetPropertyValue", TypeDesc.BOOLEAN, params);
break;
}
case HAS_READ_METHOD: {
TypeDesc[] params = {TypeDesc.STRING};
mi = cf.addMethod(Modifiers.PUBLIC, "hasReadableProperty", TypeDesc.BOOLEAN, params);
break;
}
case HAS_WRITE_METHOD: {
TypeDesc[] params = {TypeDesc.STRING};
mi = cf.addMethod(Modifiers.PUBLIC, "hasWritableProperty", TypeDesc.BOOLEAN, params);
break;
}
}
mi.markSynthetic();
CodeBuilder b = new CodeBuilder(mi);
LocalVariable beanVar, propertyVar, valueVar;
switch (methodType) {