Before I start I would just like everyone know that I did indeed spend a good time googling this and found a lot of explanations and definitions. But even so after spending hours reading the subject still seems rather vague. I know I have to ask questions that can better the community but this one is just for me to see if I have a clear understanding of JavaBeans.
From what I can make out, a JavaBean is basically a class just like any other java class except that it adheres to certain conventions, i.e.:
- The class must implement Serializeable
- Class properties are assumed to be private and their names start with a lowercase letter
- Each property must have it's respective getter and setter methods.
- Each setter method starts with the prefix 'get' followed by the property name e.g. setName()
- Setter methods are public and void
- Same applies to the getter methods (prefix 'get', public, return type respective property class type etc.)
- For boolean properties instead of 'get' one uses the prefix 'is'
- Strictly speaking it is the instance of the class that is considered a 'bean' not the class itself.
And there you have it, after a very long time of reading, that's what I can make out... Is that it? Am I close? Do I have this completely wrong?
...Thanks for everyone's answers so that I could update this bullet list :-)