Dynamically generate getter/setter method for object