T - the type of the underlying Java objectpublic class SimpleItem<T> extends Object implements BackedItem<T>
Item implementation backed by a Java object.
Item Propertys are defined by PropertyDefs and retrieved by a PropertyExtractor.
Although the item properties are read-only from "above", they can be made mutable from "below" by modifying the
backing object and invoking fireValueChange().
| Modifier and Type | Class and Description |
|---|---|
class |
SimpleItem.Property<V>
SimpleItem.Property implementation used by SimpleItem. |
Item.Editor, Item.PropertySetChangeEvent, Item.PropertySetChangeListener, Item.PropertySetChangeNotifier, Item.Viewer| Modifier and Type | Field and Description |
|---|---|
protected T |
object |
protected PropertyExtractor<? super T> |
propertyExtractor |
| Constructor and Description |
|---|
SimpleItem(T object,
Collection<? extends PropertyDef<?>> propertyDefs,
PropertyExtractor<? super T> propertyExtractor)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addItemProperty(Object id,
Property property) |
protected <V> SimpleItem.Property<V> |
createProperty(PropertyDef<V> propertyDef)
Create a
SimpleItem.Property to be used for the given property definition. |
void |
fireValueChange()
Issue
Property.ValueChangeEvents to all
Property.ValueChangeListeners registered on any property of this item. |
void |
fireValueChange(String propertyName)
Issue
Property.ValueChangeEvents to all
Property.ValueChangeListeners registered on the specified property of this item. |
SimpleItem.Property<?> |
getItemProperty(Object id) |
Set<String> |
getItemPropertyIds() |
T |
getObject()
Retrieve the underlying Java object.
|
boolean |
removeItemProperty(Object id) |
protected final T object
protected final PropertyExtractor<? super T> propertyExtractor
public SimpleItem(T object, Collection<? extends PropertyDef<?>> propertyDefs, PropertyExtractor<? super T> propertyExtractor)
object - underlying Java objectpropertyDefs - property definitionspropertyExtractor - extracts the property value from objectIllegalArgumentException - if any parameter is nullpublic T getObject()
BackedItemgetObject in interface BackedItem<T>public SimpleItem.Property<?> getItemProperty(Object id)
getItemProperty in interface Itempublic Set<String> getItemPropertyIds()
getItemPropertyIds in interface Itempublic boolean addItemProperty(Object id, Property property)
addItemProperty in interface ItemUnsupportedOperationException - alwayspublic boolean removeItemProperty(Object id)
removeItemProperty in interface ItemUnsupportedOperationException - alwayspublic void fireValueChange(String propertyName)
Property.ValueChangeEvents to all
Property.ValueChangeListeners registered on the specified property of this item.
Does nothing if propertyName is not one of this item's properties.
propertyName - property IDpublic void fireValueChange()
Property.ValueChangeEvents to all
Property.ValueChangeListeners registered on any property of this item.protected <V> SimpleItem.Property<V> createProperty(PropertyDef<V> propertyDef)
SimpleItem.Property to be used for the given property definition.
This method will be invoked at most once for any property; the returned value is cached.
The implementation in SimpleItem returns new Property<V>(propertyDef).
V - property typepropertyDef - property definitionIllegalArgumentException - if propertyDef is nullCopyright © 2017. All rights reserved.