Java Reference
In-Depth Information
specializations of these interfaces also exist for List , Map , and Set . they are designed for working with
observable collections. We cover observable collections in Chapter 7.
Note
A Common Theme for Type-Specific Interfaces
Although the generic interfaces are not all specialized in exactly the same way, a common theme exists:
The
Boolean type is specialized directly.
The
Integer , Long , Float , and Double types are specialized through the Number supertype.
String type is specialized through the Object type.
This theme exists in the type-specific specializations of all the key interfaces. As an example, we examine the
subinterfaces of the ObservableValue<T> interface:
The
ObservableBooleanValue extends ObservableValue<Boolean> , and it offers one additional
method.
boolean get();
ObservableNumberValue extends ObservableValue<Number> , and it offers four additional
methods.
int intValue();
long longValue();
float floatValue();
double doubleValue();
ObservableObjectValue<T> extends ObservableValue<t> , and it offers one additional
method.
T get();
ObservableIntegerValue , ObservableLongValue , ObservableFloatValue , and
ObservableDoubleValue extend ObservableNumberValue and each offers an additional get()
method that returns the appropriate primitive type value.
ObservableStringValue extends ObservableObjectValue<String> and inherits its get()
method that returns String .
Notice that the get() method that we have been using in the examples is defined in the type-specific
ObservableValue subinterfaces. A similar examination reveals that the set() method that we have been using in the
examples is defined in the type-specific WritableValue subinterfaces.
A practical consequence of this derivation hierarchy is that any numerical property can call bind() on any other
numerical property or binding. Indeed, the signature of the bind() method on any numerical property is
void bind(ObservableValue<? extends Number> observable);
and any numerical property and binding is assignable to the generic parameter type. The program in Listing 4-4
shows that any numerical properties of different specific types can be bound to each other.
 
 
Search WWH ::




Custom Search