How JavaBean Properties Should Look Like

During a discussion about JavaBean properties in JSF managed beans and entity classes I had an idea for simplify the usage of properties. Because specially in managed beans the getter and setter are annoying and make the code hard to read.

In my opinion the C# way is straight forward:

public class TimePeriod {
private double hours;

public double Hours {
get { return hours; }
set { hours = value; }
}
}

But for a simple case like this the C# way is still to complicated.
So why not use annotations and a new modifier called property. For example

public class TimePeriod {
@Get @Set
property double hours;
}

With the annotations one defines if a property is read-write, write-only or read-only. The new keyword “property” defines how to access the property.I like the possibility in C# to use = operator for getting and setting the properties value. So “property” indicates that one can use = to access the value.

And if you don’t like the default behavior you could still override the get and set method for the property.