Well, the JavaBean API defines a number of conventions regarding to JavaBeans. According to Wikipedia:
The required conventions are as follows:
- The class must have a public default constructor (no-argument). This allows easy instantiation within editing and activation frameworks.
- The class properties must be accessible using get, set, is (used for boolean properties instead of get) and other methods (so-called
accessor methods and mutator methods), following a standard naming
convention. This allows easy automated inspection and updating of bean
state within frameworks, many of which include custom editors for
various types of properties. Setters must receive only one argument.
- The class should be serializable. It allows applications and frameworks to reliably save, store, and restore the bean's state in a
fashion independent of the VM and of the platform.
Quite often, these are the most common types of classes that can be found in an application, as they can be used to model the data that is used. An example of such a bean can be seen below:
public class Person implements Serializable
{
private String name;
private boolean alive;
public Person()
{
// constructor logic...
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public boolean isAlive()
{
return alive;
}
public void setAlive(boolean alive)
{
this.alive = alive;
}
}
As you can see, properties are reflected in the getters and setters.
HTH