*
* <p>
* If the wrapped container is changed directly (that is, not through the
- * wrapper), the hierarchy information must be updated with the
- * {@link #updateHierarchicalWrapper()} method.
+ * wrapper), and does not implement Container.ItemSetChangeNotifier and/or
+ * Container.PropertySetChangeNotifier the hierarchy information must be updated
+ * with the {@link #updateHierarchicalWrapper()} method.
* </p>
*
* @author IT Mill Ltd.
public Object addItem() throws UnsupportedOperationException {
final Object id = container.addItem();
- if (id != null) {
+ if (!hierarchical && id != null) {
addToHierarchyWrapper(id);
}
return id;
public Item addItem(Object itemId) throws UnsupportedOperationException {
final Item item = container.addItem(itemId);
- if (item != null) {
+ if (!hierarchical && item != null) {
addToHierarchyWrapper(itemId);
}
return item;
final boolean success = container.removeAllItems();
- if (success) {
+ if (!hierarchical && success) {
roots.clear();
parent.clear();
children.clear();
final boolean success = container.removeItem(itemId);
- if (success) {
+ if (!hierarchical && success) {
removeFromHierarchyWrapper(itemId);
}
}
public boolean equals(Object obj) {
- return listener.equals(obj);
+ return obj == listener || (obj != null && obj.equals(listener));
}
public int hashCode() {
*
* <p>
* If the wrapped container is changed directly (that is, not through the
- * wrapper), the ordering must be updated with the {@link #updateOrderWrapper()}
- * method.
+ * wrapper), and does not implement Container.ItemSetChangeNotifier and/or
+ * Container.PropertySetChangeNotifier the hierarchy information must be updated
+ * with the {@link #updateOrderWrapper()} method.
* </p>
*
* @author IT Mill Ltd.
}
public boolean equals(Object obj) {
- return listener.equals(obj);
+ return obj == listener || (obj != null && obj.equals(listener));
}
public int hashCode() {