Chapter 4. Properties
Properties are named attributes or characteristics. They define the
behavior and state of an object. For instance, the current
temperature value of the Temperature object is a
property, as are the high and low temperature thresholds of the
GenericTemperatureThresholdAdapter from the
previous chapter. Properties are referenced by their name and can
have any type, including primitives such as int,
and class and interface types such as
java.awt.Color. The name of the low threshold
property is LowThreshold, and its type is
double. Properties are usually part of the
persistent state of an object. This will be dealt with later in Chapter 5.
Properties are exposed to visual programming tools and scripting environments, as well as to traditional Java programming. They are manipulated in a visual programming tool through some kind of property-editing interface. In a scripting environment, properties are exposed through a field-style syntax such as Object.Property = value, and value = Object.Property. These are syntactical conveniences provided by the scripting environment. As a Beans developer, you’ll expose your properties as described in the rest of this chapter.
Accessing Properties
An object’s properties are accessed by calling methods that are defined for setting and getting the property value. Any property that can be read will have an associated method for getting its value. Likewise, any property that can be written will have an associated method for setting ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access