Sometimes when i have some object with lots of attributes (for example 30-40) it is really anoying to write getter and setter methods so in javascript i do something like this:
function SomeObject( properties )
{
// Iterate through the properties of the object, and make sure
// that it's properly scoped.
for ( var i in properties )
{
(function(){
// Create a new getter for the property
this[ "get" + i ] = function()
{
return properties[i];
};
// Create a new setter for the property
this[ "set" + i ] = function(val)
{
properties[i] = val;
};
})(); }
}
So i am just wondering if it is possible to do something like this in JAVA?