Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2007-11-14 05:22:49 +0000
committerbvosburgh2007-11-14 05:22:49 +0000
commit5c1fb4ba984041adb7f7246decc11a0f4e2d447f (patch)
tree32d6ef2c8856f0db16f5b3852bb0b144f09e0183
parent79f9ec9e6f53e266814781283e09d09277f8f227 (diff)
downloadwebtools.dali-5c1fb4ba984041adb7f7246decc11a0f4e2d447f.tar.gz
webtools.dali-5c1fb4ba984041adb7f7246decc11a0f4e2d447f.tar.xz
webtools.dali-5c1fb4ba984041adb7f7246decc11a0f4e2d447f.zip
[201159] model rework: read-only CollectionValueModel
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractReadOnlyCollectionValueModel.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ReadOnlyCollectionValueModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java144
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java24
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java221
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java9
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java10
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java18
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java22
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java56
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java10
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ReadOnlyCollectionValueModelTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java40
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SynchronizedBag.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java6
33 files changed, 377 insertions, 457 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java
index 18ce872372..34a9a8a4e3 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/AbstractModel.java
@@ -257,7 +257,7 @@ public abstract class AbstractModel implements Model, Serializable {
* Remove the specified items from the specified bound collection
* and fire the appropriate event if necessary.
* Return whether the collection changed.
- * @see java.util.Collection#remove(Object)
+ * @see java.util.Collection#removeAll(Collection)
*/
protected boolean removeItemsFromCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
return this.removeItemsFromCollection(items.iterator(), collection, collectionName);
@@ -268,7 +268,7 @@ public abstract class AbstractModel implements Model, Serializable {
* Remove the specified items from the specified bound collection
* and fire the appropriate event if necessary.
* Return whether the collection changed.
- * @see java.util.Collection#remove(Object)
+ * @see java.util.Collection#removeAll(Collection)
*/
protected boolean removeItemsFromCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
Collection<?> items2 = CollectionTools.collection(items);
@@ -283,6 +283,36 @@ public abstract class AbstractModel implements Model, Serializable {
/**
* Convenience method.
+ * Retain the specified items in the specified bound collection
+ * and fire the appropriate event if necessary.
+ * Return whether the collection changed.
+ * @see java.util.Collection#retainAll(Collection)
+ */
+ protected boolean retainItemsInCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
+ return this.retainItemsInCollection(items.iterator(), collection, collectionName);
+ }
+
+ /**
+ * Convenience method.
+ * Retain the specified items in the specified bound collection
+ * and fire the appropriate event if necessary.
+ * Return whether the collection changed.
+ * @see java.util.Collection#retainAll(Collection)
+ */
+ protected boolean retainItemsInCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
+ Collection<?> items2 = CollectionTools.collection(items);
+ Collection<?> removedItems = CollectionTools.collection(collection);
+ removedItems.removeAll(items2);
+ boolean changed = collection.retainAll(items2);
+
+ if ( ! removedItems.isEmpty()) {
+ this.fireItemsRemoved(collectionName, removedItems);
+ }
+ return changed;
+ }
+
+ /**
+ * Convenience method.
* Clear the entire collection
* and fire the appropriate event if necessary.
* Return whether the list changed.
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractReadOnlyCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractReadOnlyCollectionValueModel.java
index a2838845d4..2a5216ff8d 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractReadOnlyCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/AbstractReadOnlyCollectionValueModel.java
@@ -51,24 +51,8 @@ public abstract class AbstractReadOnlyCollectionValueModel
// ********** CollectionValueModel implementation **********
- public void add(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void addAll(Collection items) {
- throw new UnsupportedOperationException();
- }
-
- public void remove(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAll(Collection items) {
- throw new UnsupportedOperationException();
- }
-
public int size() {
- return CollectionTools.size((Iterator) this.values());
+ return CollectionTools.size((Iterator) this.iterator());
}
@@ -76,7 +60,7 @@ public abstract class AbstractReadOnlyCollectionValueModel
@Override
public String toString() {
- return StringTools.buildToStringFor(this, CollectionTools.collection((Iterator) this.values()));
+ return StringTools.buildToStringFor(this, CollectionTools.collection((Iterator) this.iterator()));
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
index a5d6744158..dc93fd027c 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
@@ -121,7 +121,7 @@ public abstract class CollectionAspectAdapter
* Return the value of the subject's collection aspect.
* This should be an *iterator* on the collection.
*/
- public Iterator values() {
+ public Iterator iterator() {
if (this.subject == null) {
return EmptyIterator.instance();
}
@@ -132,45 +132,13 @@ public abstract class CollectionAspectAdapter
* Return the value of the subject's collection aspect.
* This should be an *iterator* on the collection.
* At this point we can be sure that the subject is not null.
- * @see #values()
+ * @see #iterator()
*/
protected Iterator getValueFromSubject() {
throw new UnsupportedOperationException();
}
/**
- * Add the specified item to the subject's collection aspect.
- */
- public void add(Object item) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Add the specified items to the subject's collection aspect.
- */
- public void addAll(Collection items) {
- for (Iterator stream = items.iterator(); stream.hasNext(); ) {
- this.add(stream.next());
- }
- }
-
- /**
- * Remove the specified item from the subject's collection aspect.
- */
- public void remove(Object item) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Remove the specified items from the subject's collection aspect.
- */
- public void removeAll(Collection items) {
- for (Iterator stream = items.iterator(); stream.hasNext(); ) {
- this.remove(stream.next());
- }
- }
-
- /**
* Return the size of the collection value.
*/
public int size() {
@@ -183,7 +151,7 @@ public abstract class CollectionAspectAdapter
* @see #size()
*/
protected int sizeFromSubject() {
- return CollectionTools.size((Iterator) this.values());
+ return CollectionTools.size((Iterator) this.iterator());
}
@@ -191,7 +159,7 @@ public abstract class CollectionAspectAdapter
@Override
protected Object value() {
- return this.values();
+ return this.iterator();
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
index 997fa8b7dd..22d750b47f 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
@@ -228,7 +228,7 @@ public class CollectionListValueModelAdapter
// ********** behavior **********
protected void buildList() {
- Iterator stream = (Iterator) this.collectionHolder.values();
+ Iterator stream = (Iterator) this.collectionHolder.iterator();
// if the new collection is empty, do nothing
if (stream.hasNext()) {
this.list.ensureCapacity(this.collectionHolder.size());
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java
index 0842e835a7..bc17035f97 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java
@@ -9,7 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.utility.internal.model.value;
-import java.util.Collection;
import java.util.Iterator;
import org.eclipse.jpt.utility.internal.model.Model;
@@ -19,36 +18,16 @@ import org.eclipse.jpt.utility.internal.model.Model;
* change notification and make it more pluggable.
*/
public interface CollectionValueModel
- extends Model
+ extends Model//, Iterable<E>
{
/**
* Return the collection's values.
*/
- Iterator values();
+ Iterator iterator();
String VALUES = "values";
/**
- * Add the specified item to the collection.
- */
- void add(Object item);
-
- /**
- * Add the specified items to the collection.
- */
- void addAll(Collection items);
-
- /**
- * Remove the specified item from the collection.
- */
- void remove(Object item);
-
- /**
- * Remove the specified items from the collection.
- */
- void removeAll(Collection items);
-
- /**
* Return the size of the collection value.
*/
int size();
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
index 9228dec61c..c1a9b31a92 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
@@ -124,35 +124,6 @@ public abstract class CollectionValueModelWrapper
}
- // ********** CollectionValueModel implementation **********
-
- /**
- * wrappers cannot be modified - the underlying model must be modified directly
- */
- public void add(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void addAll(Collection items) {
- for (Iterator stream = items.iterator(); stream.hasNext(); ) {
- this.add(stream.next());
- }
- }
-
- /**
- * wrappers cannot be modified - the underlying model must be modified directly
- */
- public void remove(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAll(Collection items) {
- for (Iterator stream = items.iterator(); stream.hasNext(); ) {
- this.remove(stream.next());
- }
- }
-
-
// ********** behavior **********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
index 8d8994a417..2fd599019e 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
@@ -135,7 +135,7 @@ public class CompositeCollectionValueModel
// ********** CollectionValueModel implementation **********
- public Iterator values() {
+ public Iterator iterator() {
return new CompositeIterator(this.buildCollectionsIterators());
}
@@ -162,7 +162,7 @@ public class CompositeCollectionValueModel
// the following will trigger the firing of a number of unnecessary events
// (since we don't have any listeners yet),
// but it reduces the amount of duplicate code
- this.addComponentSources((Iterator) this.collectionHolder.values());
+ this.addComponentSources((Iterator) this.collectionHolder.iterator());
}
@Override
@@ -268,7 +268,7 @@ public class CompositeCollectionValueModel
protected void collectionChanged(CollectionChangeEvent e) {
// copy the keys so we don't eat our own tail
this.removeComponentSources(new ArrayList(this.components.keySet()).iterator());
- this.addComponentSources((Iterator) this.collectionHolder.values());
+ this.addComponentSources((Iterator) this.collectionHolder.iterator());
}
@@ -315,7 +315,7 @@ public class CompositeCollectionValueModel
* Update our cache.
*/
protected void addComponentItems(CollectionValueModel itemsHolder, ArrayList componentCollection) {
- this.addComponentItems((Iterator) itemsHolder.values(), itemsHolder.size(), componentCollection);
+ this.addComponentItems((Iterator) itemsHolder.iterator(), itemsHolder.size(), componentCollection);
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
index 612d8aa6fa..1792ffdf7f 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
@@ -114,7 +114,7 @@ public class FilteringCollectionValueModel
// ********** CollectionValueModel implementation **********
- public Iterator values() {
+ public Iterator iterator() {
return this.filteredItems.iterator();
}
@@ -196,7 +196,7 @@ public class FilteringCollectionValueModel
*/
protected void synchFilteredItems() {
this.filteredItems.clear();
- CollectionTools.addAll(this.filteredItems, this.filter(this.collectionHolder.values()));
+ CollectionTools.addAll(this.filteredItems, this.filter(this.collectionHolder.iterator()));
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
index cfc9b67a69..13cace2d94 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
@@ -108,27 +108,11 @@ public class ListCollectionValueModelAdapter
// ********** CollectionValueModel implementation **********
- public Iterator values() {
+ public Iterator iterator() {
// try to prevent backdoor modification of the list
return new ReadOnlyIterator(this.collection);
}
- public void add(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void addAll(Collection items) {
- throw new UnsupportedOperationException();
- }
-
- public void remove(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAll(Collection items) {
- throw new UnsupportedOperationException();
- }
-
public int size() {
return this.collection.size();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
index a86a209bfe..767a915369 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
@@ -50,7 +50,7 @@ public final class NullCollectionValueModel
return 0;
}
- public Iterator values() {
+ public Iterator iterator() {
return EmptyIterator.instance();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
index 3a553ff346..8414392fbf 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
@@ -82,29 +82,13 @@ public class PropertyCollectionValueModelAdapter
// ********** CollectionValueModel implementation **********
- public Iterator values() {
+ public Iterator iterator() {
return (this.value == null) ?
EmptyIterator.instance()
:
new SingleElementIterator(this.value);
}
- public void add(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void addAll(Collection items) {
- throw new UnsupportedOperationException();
- }
-
- public void remove(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAll(Collection items) {
- throw new UnsupportedOperationException();
- }
-
public int size() {
return (this.value == null) ? 0 : 1;
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ReadOnlyCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ReadOnlyCollectionValueModel.java
index 515a618d9a..cafbace89e 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ReadOnlyCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ReadOnlyCollectionValueModel.java
@@ -44,7 +44,7 @@ public class ReadOnlyCollectionValueModel
return this.value.size();
}
- public Iterator values() {
+ public Iterator iterator() {
return this.value.iterator();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
index 54e341e615..6e7b32d271 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
@@ -13,31 +13,36 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.internal.model.ChangeSupport;
import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
import org.eclipse.jpt.utility.internal.model.listener.CollectionChangeListener;
/**
- * Implementation of CollectionValueModel that simply holds on to a
- * collection and uses it as the value.
+ * Implementation of CollectionValueModel and Collection that simply holds a
+ * collection and notifies listeners of any changes.
*/
-public class SimpleCollectionValueModel
+public class SimpleCollectionValueModel<E>
extends AbstractModel
- implements CollectionValueModel
+ implements CollectionValueModel, Collection<E>
{
/** The value. */
- protected Collection value;
+ protected Collection<E> collection;
+ // ********** constructors **********
+
/**
- * Construct a CollectionValueModel for the specified value.
+ * Construct a CollectionValueModel for the specified collection.
*/
- public SimpleCollectionValueModel(Collection value) {
+ public SimpleCollectionValueModel(Collection<E> collection) {
super();
- this.setValue(value);
+ if (collection == null) {
+ throw new NullPointerException();
+ }
+ this.collection = collection;
}
/**
@@ -45,7 +50,7 @@ public class SimpleCollectionValueModel
* value of an empty collection.
*/
public SimpleCollectionValueModel() {
- this(new HashBag());
+ this(new HashBag<E>());
}
@Override
@@ -56,57 +61,122 @@ public class SimpleCollectionValueModel
// ********** CollectionValueModel implementation **********
- public Iterator values() {
- // try to prevent backdoor modification of the collection
- return new ReadOnlyIterator(this.value);
+ public Iterator<E> iterator() {
+ return new LocalIterator<E>(this.collection.iterator());
}
- public void add(Object item) {
- this.addItemToCollection(item, this.value, VALUES);
+ private class LocalIterator<T> implements Iterator<T> {
+ private final Iterator<T> iterator;
+ private T next;
+ LocalIterator(Iterator<T> iterator) {
+ super();
+ this.iterator = iterator;
+ }
+ public boolean hasNext() {
+ return this.iterator.hasNext();
+ }
+ public T next() {
+ return this.next = this.iterator.next();
+ }
+ @SuppressWarnings("synthetic-access")
+ public void remove() {
+ this.iterator.remove();
+ SimpleCollectionValueModel.this.fireItemRemoved(VALUES, this.next);
+ }
}
- public void addAll(Collection items) {
- this.addItemsToCollection(items, this.value, VALUES);
+ public int size() {
+ return this.collection.size();
}
- public void remove(Object item) {
- this.removeItemFromCollection(item, this.value, VALUES);
+
+ // ********** Collection implementation **********
+
+ public boolean isEmpty() {
+ return this.collection.isEmpty();
}
- public void removeAll(Collection items) {
- this.removeItemsFromCollection(items, this.value, VALUES);
+ public boolean contains(Object o) {
+ return this.collection.contains(o);
}
- public int size() {
- return this.value.size();
+ public Object[] toArray() {
+ return this.collection.toArray();
+ }
+
+ public <T extends Object> T[] toArray(T[] a) {
+ return this.collection.toArray(a);
}
+ public boolean add(E o) {
+ return this.addItemToCollection(o, this.collection, VALUES);
+ }
- // ********** behavior **********
+ public boolean remove(Object o) {
+ return this.removeItemFromCollection(o, this.collection, VALUES);
+ }
- /**
- * Allow the value to be replaced.
- */
- public void setValue(Collection value) {
- this.value = ((value == null) ? new HashBag() : value);
- this.fireCollectionChanged(VALUES);
+ public boolean containsAll(Collection<?> c) {
+ return this.collection.containsAll(c);
+ }
+
+ public boolean addAll(Collection<? extends E> c) {
+ return this.addItemsToCollection(c, this.collection, VALUES);
+ }
+
+ public boolean removeAll(Collection<?> c) {
+ return this.removeItemsFromCollection(c, this.collection, VALUES);
+ }
+
+ public boolean retainAll(Collection<?> c) {
+ return this.retainItemsInCollection(c, this.collection, VALUES);
}
- /**
- * Allow the value to be cleared.
- */
public void clear() {
- if (this.value.isEmpty()) {
+ if (this.collection.isEmpty()) {
return;
}
- Collection items = new ArrayList(this.value);
- this.value.clear();
+ Collection<E> items = new ArrayList<E>(this.collection);
+ this.collection.clear();
this.fireItemsRemoved(VALUES, items);
}
@Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if ((o instanceof Collection) && (o instanceof CollectionValueModel)) {
+ Collection<E> c1 = CollectionTools.collection(this.collection);
+ @SuppressWarnings("unchecked")
+ Collection<E> c2 = CollectionTools.collection(((Collection<E>) o).iterator());
+ return c1.equals(c2);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return CollectionTools.collection(this.collection).hashCode();
+ }
+
+
+ // ********** additional behavior **********
+
+ /**
+ * Allow the value to be replaced.
+ */
+ public void setCollection(Collection<E> collection) {
+ if (collection == null) {
+ throw new NullPointerException();
+ }
+ this.collection = collection;
+ this.fireCollectionChanged(VALUES);
+ }
+
+ @Override
public void toString(StringBuilder sb) {
- sb.append(this.value);
+ sb.append(this.collection);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
index 52cdddaf62..d9144c0495 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
@@ -87,30 +87,10 @@ public class PreferencesCollectionValueModel
/**
* Return an iterator on the preference models.
*/
- public synchronized Iterator values() {
+ public synchronized Iterator iterator() {
return this.preferences.values().iterator();
}
- public void add(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void addAll(Collection items) {
- for (Iterator stream = items.iterator(); stream.hasNext(); ) {
- this.add(stream.next());
- }
- }
-
- public void remove(Object item) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAll(Collection items) {
- for (Iterator stream = items.iterator(); stream.hasNext(); ) {
- this.remove(stream.next());
- }
- }
-
public synchronized int size() {
return this.preferences.size();
}
@@ -120,7 +100,7 @@ public class PreferencesCollectionValueModel
@Override
protected Object value() {
- return this.values();
+ return this.iterator();
}
@Override
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java
index 34763968bd..6e61681ba9 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionAspectAdapterTests.java
@@ -31,7 +31,7 @@ import junit.framework.TestCase;
public class CollectionAspectAdapterTests extends TestCase {
private TestSubject subject1;
private PropertyValueModel subjectHolder1;
- private CollectionAspectAdapter aa1;
+ private LocalCollectionAspectAdapter aa1;
private CollectionChangeEvent event1;
private CollectionChangeListener listener1;
private String event1Type;
@@ -93,40 +93,8 @@ public class CollectionAspectAdapterTests extends TestCase {
return result;
}
- private CollectionAspectAdapter buildAspectAdapter(ValueModel subjectHolder) {
- return new CollectionAspectAdapter(subjectHolder, TestSubject.NAMES_COLLECTION) {
- // this is not a typical aspect adapter - the value is determined by the aspect name
- @Override
- protected Iterator<String> getValueFromSubject() {
- if (this.collectionName == TestSubject.NAMES_COLLECTION) {
- return ((TestSubject) this.subject).names();
- } else if (this.collectionName == TestSubject.DESCRIPTIONS_COLLECTION) {
- return ((TestSubject) this.subject).descriptions();
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.collectionName);
- }
- }
- @Override
- public void add(Object item) {
- if (this.collectionName == TestSubject.NAMES_COLLECTION) {
- ((TestSubject) this.subject).addName((String) item);
- } else if (this.collectionName == TestSubject.DESCRIPTIONS_COLLECTION) {
- ((TestSubject) this.subject).addDescription((String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.collectionName);
- }
- }
- @Override
- public void remove(Object item) {
- if (this.collectionName == TestSubject.NAMES_COLLECTION) {
- ((TestSubject) this.subject).removeName((String) item);
- } else if (this.collectionName == TestSubject.DESCRIPTIONS_COLLECTION) {
- ((TestSubject) this.subject).removeDescription((String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.collectionName);
- }
- }
- };
+ private LocalCollectionAspectAdapter buildAspectAdapter(ValueModel subjectHolder) {
+ return new LocalCollectionAspectAdapter(subjectHolder);
}
private CollectionChangeListener buildValueChangeListener1() {
@@ -158,7 +126,7 @@ public class CollectionAspectAdapterTests extends TestCase {
}
public void testSubjectHolder() {
- assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.iterator()));
assertNull(this.event1);
this.subjectHolder1.setValue(this.subject2);
@@ -167,7 +135,7 @@ public class CollectionAspectAdapterTests extends TestCase {
assertEquals(this.aa1, this.event1.getSource());
assertEquals(CollectionValueModel.VALUES, this.event1.collectionName());
assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject2Names(), CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(this.subject2Names(), CollectionTools.bag((Iterator) this.aa1.iterator()));
this.event1 = null;
this.event1Type = null;
@@ -177,7 +145,7 @@ public class CollectionAspectAdapterTests extends TestCase {
assertEquals(this.aa1, this.event1.getSource());
assertEquals(CollectionValueModel.VALUES, this.event1.collectionName());
assertFalse(this.event1.items().hasNext());
- assertFalse(((Iterator) this.aa1.values()).hasNext());
+ assertFalse(((Iterator) this.aa1.iterator()).hasNext());
this.event1 = null;
this.event1Type = null;
@@ -187,11 +155,11 @@ public class CollectionAspectAdapterTests extends TestCase {
assertEquals(this.aa1, this.event1.getSource());
assertEquals(CollectionValueModel.VALUES, this.event1.collectionName());
assertFalse(this.event1.items().hasNext());
- assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.iterator()));
}
public void testAdd() {
- assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.iterator()));
assertNull(this.event1);
this.subject1.addName("jam");
@@ -202,7 +170,7 @@ public class CollectionAspectAdapterTests extends TestCase {
assertEquals("jam", this.event1.items().next());
Collection namesPlus = this.subject1Names();
namesPlus.add("jam");
- assertEquals(namesPlus, CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(namesPlus, CollectionTools.bag((Iterator) this.aa1.iterator()));
this.event1 = null;
this.event1Type = null;
@@ -213,11 +181,11 @@ public class CollectionAspectAdapterTests extends TestCase {
assertEquals(CollectionValueModel.VALUES, this.event1.collectionName());
assertEquals("jaz", this.event1.items().next());
namesPlus.add("jaz");
- assertEquals(namesPlus, CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(namesPlus, CollectionTools.bag((Iterator) this.aa1.iterator()));
}
public void testRemove() {
- assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.iterator()));
assertNull(this.event1);
this.subject1.removeName("foo");
@@ -228,7 +196,7 @@ public class CollectionAspectAdapterTests extends TestCase {
assertEquals("foo", this.event1.items().next());
Collection namesMinus = this.subject1Names();
namesMinus.remove("foo");
- assertEquals(namesMinus, CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(namesMinus, CollectionTools.bag((Iterator) this.aa1.iterator()));
this.event1 = null;
this.event1Type = null;
@@ -239,11 +207,11 @@ public class CollectionAspectAdapterTests extends TestCase {
assertEquals(CollectionValueModel.VALUES, this.event1.collectionName());
assertEquals("bar", this.event1.items().next());
namesMinus.remove("bar");
- assertEquals(namesMinus, CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(namesMinus, CollectionTools.bag((Iterator) this.aa1.iterator()));
}
public void testCollectionChange() {
- assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.iterator()));
assertNull(this.event1);
this.subject1.addTwoNames("jam", "jaz");
@@ -255,17 +223,17 @@ public class CollectionAspectAdapterTests extends TestCase {
Collection namesPlus2 = this.subject1Names();
namesPlus2.add("jam");
namesPlus2.add("jaz");
- assertEquals(namesPlus2, CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(namesPlus2, CollectionTools.bag((Iterator) this.aa1.iterator()));
}
- public void testValues() {
+ public void testIterator() {
assertEquals(this.subject1Names(), CollectionTools.bag(this.subject1.names()));
- assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.values()));
+ assertEquals(this.subject1Names(), CollectionTools.bag((Iterator) this.aa1.iterator()));
}
public void testSize() {
assertEquals(this.subject1Names().size(), CollectionTools.size(this.subject1.names()));
- assertEquals(this.subject1Names().size(), CollectionTools.size((Iterator) this.aa1.values()));
+ assertEquals(this.subject1Names().size(), CollectionTools.size((Iterator) this.aa1.iterator()));
}
public void testHasListeners() {
@@ -284,65 +252,118 @@ public class CollectionAspectAdapterTests extends TestCase {
assertFalse(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
}
-// ********** inner class **********
-
-private class TestSubject extends AbstractModel {
- private Collection<String> names;
- public static final String NAMES_COLLECTION = "names";
- private Collection<String> descriptions;
- public static final String DESCRIPTIONS_COLLECTION = "descriptions";
- public TestSubject() {
- this.names = new HashBag<String>();
- this.descriptions = new HashBag<String>();
- }
- public Iterator<String> names() {
- return new ReadOnlyIterator<String>(this.names);
- }
- public void addName(String name) {
- if (this.names.add(name)) {
- this.fireItemAdded(NAMES_COLLECTION, name);
+ // ********** inner class **********
+
+ private class TestSubject extends AbstractModel {
+ private Collection<String> names;
+ public static final String NAMES_COLLECTION = "names";
+ private Collection<String> descriptions;
+ public static final String DESCRIPTIONS_COLLECTION = "descriptions";
+
+ public TestSubject() {
+ this.names = new HashBag<String>();
+ this.descriptions = new HashBag<String>();
}
- }
- public void addNames(Iterator<String> newNames) {
- while (newNames.hasNext()) {
- this.addName(newNames.next());
+ public Iterator<String> names() {
+ return new ReadOnlyIterator<String>(this.names);
}
- }
- public void addNames(Collection<String> newNames) {
- this.addNames(newNames.iterator());
- }
- public void addTwoNames(String name1, String name2) {
- if (this.names.add(name1) | this.names.add(name2)) {
- this.fireCollectionChanged(NAMES_COLLECTION);
+ public void addName(String name) {
+ if (this.names.add(name)) {
+ this.fireItemAdded(NAMES_COLLECTION, name);
+ }
}
- }
- public void removeName(String name) {
- if (this.names.remove(name)) {
- this.fireItemRemoved(NAMES_COLLECTION, name);
+ public void addNames(Iterator<String> newNames) {
+ while (newNames.hasNext()) {
+ this.addName(newNames.next());
+ }
}
- }
- public Iterator<String> descriptions() {
- return new ReadOnlyIterator<String>(this.descriptions);
- }
- public void addDescription(String description) {
- if (this.descriptions.add(description)) {
- this.fireItemAdded(DESCRIPTIONS_COLLECTION, description);
+ public void addNames(Collection<String> newNames) {
+ this.addNames(newNames.iterator());
}
- }
- public void addDescriptions(Iterator<String> newDescriptions) {
- while (newDescriptions.hasNext()) {
- this.addDescription(newDescriptions.next());
+ public void addTwoNames(String name1, String name2) {
+ if (this.names.add(name1) | this.names.add(name2)) {
+ this.fireCollectionChanged(NAMES_COLLECTION);
+ }
+ }
+ public void removeName(String name) {
+ if (this.names.remove(name)) {
+ this.fireItemRemoved(NAMES_COLLECTION, name);
+ }
+ }
+ public Iterator<String> descriptions() {
+ return new ReadOnlyIterator<String>(this.descriptions);
+ }
+ public void addDescription(String description) {
+ if (this.descriptions.add(description)) {
+ this.fireItemAdded(DESCRIPTIONS_COLLECTION, description);
+ }
+ }
+ public void addDescriptions(Iterator<String> newDescriptions) {
+ while (newDescriptions.hasNext()) {
+ this.addDescription(newDescriptions.next());
+ }
+ }
+ public void addDescriptions(Collection<String> newDescriptions) {
+ this.addDescriptions(newDescriptions.iterator());
+ }
+ public void removeDescription(String description) {
+ if (this.descriptions.remove(description)) {
+ this.fireItemRemoved(DESCRIPTIONS_COLLECTION, description);
+ }
}
}
- public void addDescriptions(Collection<String> newDescriptions) {
- this.addDescriptions(newDescriptions.iterator());
- }
- public void removeDescription(String description) {
- if (this.descriptions.remove(description)) {
- this.fireItemRemoved(DESCRIPTIONS_COLLECTION, description);
+
+ // this is not a typical aspect adapter - the value is determined by the aspect name
+ private class LocalCollectionAspectAdapter extends CollectionAspectAdapter {
+
+ LocalCollectionAspectAdapter(ValueModel subjectHolder) {
+ super(subjectHolder, TestSubject.NAMES_COLLECTION);
+ }
+
+ @Override
+ protected Iterator<String> getValueFromSubject() {
+ if (this.collectionName == TestSubject.NAMES_COLLECTION) {
+ return ((TestSubject) this.subject).names();
+ } else if (this.collectionName == TestSubject.DESCRIPTIONS_COLLECTION) {
+ return ((TestSubject) this.subject).descriptions();
+ } else {
+ throw new IllegalStateException("invalid aspect name: " + this.collectionName);
+ }
+ }
+
+ public void add(Object item) {
+ if (this.collectionName == TestSubject.NAMES_COLLECTION) {
+ ((TestSubject) this.subject).addName((String) item);
+ } else if (this.collectionName == TestSubject.DESCRIPTIONS_COLLECTION) {
+ ((TestSubject) this.subject).addDescription((String) item);
+ } else {
+ throw new IllegalStateException("invalid aspect name: " + this.collectionName);
+ }
}
+
+ public void addAll(Collection items) {
+ for (Iterator stream = items.iterator(); stream.hasNext(); ) {
+ this.add(stream.next());
+ }
+ }
+
+ public void remove(Object item) {
+ if (this.collectionName == TestSubject.NAMES_COLLECTION) {
+ ((TestSubject) this.subject).removeName((String) item);
+ } else if (this.collectionName == TestSubject.DESCRIPTIONS_COLLECTION) {
+ ((TestSubject) this.subject).removeDescription((String) item);
+ } else {
+ throw new IllegalStateException("invalid aspect name: " + this.collectionName);
+ }
+ }
+
+ public void removeAll(Collection items) {
+ for (Iterator stream = items.iterator(); stream.hasNext(); ) {
+ this.remove(stream.next());
+ }
+ }
+
}
-}
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java
index e38df969cf..7ef5d20425 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java
@@ -32,7 +32,7 @@ import junit.framework.TestCase;
public class CollectionListValueModelAdapterTests extends TestCase {
private ListValueModel adapter;
- private CollectionValueModel wrappedCollectionHolder;
+ private SimpleCollectionValueModel wrappedCollectionHolder;
private Collection wrappedCollection;
public CollectionListValueModelAdapterTests(String name) {
@@ -115,6 +115,7 @@ public class CollectionListValueModelAdapterTests extends TestCase {
this.wrappedCollectionHolder.add("joo");
this.wrappedCollectionHolder.add("jar");
this.wrappedCollectionHolder.add("jaz");
+ assertTrue(this.wrappedCollection.contains("jaz"));
this.wrappedCollectionHolder.remove("jaz");
assertFalse(this.wrappedCollection.contains("jaz"));
this.wrappedCollectionHolder.remove("foo");
@@ -169,7 +170,7 @@ public class CollectionListValueModelAdapterTests extends TestCase {
this.wrappedCollectionHolder.add("bar");
this.wrappedCollectionHolder.add("baz");
JList jList = new JList(new ListModelAdapter(this.adapter));
- ((SimpleCollectionValueModel) this.wrappedCollectionHolder).setValue(new HashBag());
+ ((SimpleCollectionValueModel) this.wrappedCollectionHolder).setCollection(new HashBag());
assertEquals(0, jList.getModel().getSize());
}
@@ -183,7 +184,7 @@ public class CollectionListValueModelAdapterTests extends TestCase {
HashBag bag = new HashBag();
bag.add("foo");
bag.add("bar");
- ((SimpleCollectionValueModel) this.wrappedCollectionHolder).setValue(bag);
+ ((SimpleCollectionValueModel) this.wrappedCollectionHolder).setCollection(bag);
assertEquals(2, jList.getModel().getSize());
}
@@ -195,7 +196,7 @@ public class CollectionListValueModelAdapterTests extends TestCase {
JList jList = new JList(new ListModelAdapter(this.adapter));
HashBag bag = new HashBag();
- ((SimpleCollectionValueModel) this.wrappedCollectionHolder).setValue(bag);
+ ((SimpleCollectionValueModel) this.wrappedCollectionHolder).setCollection(bag);
assertEquals(0, jList.getModel().getSize());
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java
index e50c89fce9..5965cf214b 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java
@@ -27,7 +27,7 @@ import junit.framework.TestCase;
public class CollectionPropertyValueModelAdapterTests extends TestCase {
private PropertyValueModel adapter;
- private CollectionValueModel wrappedCollectionHolder;
+ private SimpleCollectionValueModel wrappedCollectionHolder;
PropertyChangeEvent event;
public CollectionPropertyValueModelAdapterTests(String name) {
@@ -53,7 +53,7 @@ public class CollectionPropertyValueModelAdapterTests extends TestCase {
}
private Collection wrappedCollection() {
- return CollectionTools.collection((Iterator) this.wrappedCollectionHolder.values());
+ return CollectionTools.collection((Iterator) this.wrappedCollectionHolder.iterator());
}
public void testValue() {
@@ -207,18 +207,18 @@ public class CollectionPropertyValueModelAdapterTests extends TestCase {
if (this.booleanValue()) {
if ( ! this.booleanValueOf(value)) {
// the value is changing from true to false
- this.collectionHolder.remove(this.item);
+ ((SimpleCollectionValueModel) this.collectionHolder).remove(this.item);
}
} else {
if (this.booleanValueOf(value)) {
// the value is changing from false to true
- this.collectionHolder.add(this.item);
+ ((SimpleCollectionValueModel) this.collectionHolder).add(this.item);
}
}
}
@Override
protected Object buildValue() {
- return Boolean.valueOf(CollectionTools.contains((Iterator) this.collectionHolder.values(), this.item));
+ return Boolean.valueOf(CollectionTools.contains((Iterator) this.collectionHolder.iterator(), this.item));
}
// ********** internal methods **********
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java
index b85787b708..ab6aa6cf4f 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java
@@ -59,7 +59,7 @@ public class CompositeCollectionValueModelTests extends TestCase {
}
private void verifySynch(CollectionValueModel compositeCVM) {
- assertEquals(0, CollectionTools.size((Iterator) compositeCVM.values()));
+ assertEquals(0, CollectionTools.size((Iterator) compositeCVM.iterator()));
Bag familiesSynch = new SynchronizedBag(this.buildFamiliesAspectAdapter(this.neighborhoodHolder));
Bag membersSynch = new SynchronizedBag(compositeCVM);
this.populateNeighborhood(this.neighborhood);
@@ -70,35 +70,35 @@ public class CompositeCollectionValueModelTests extends TestCase {
assertEquals(12, CollectionTools.size(this.neighborhood.allMembers()));
assertEquals(12, membersSynch.size());
assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
jetsons.removeMember(jetsons.memberNamed("Astro"));
assertEquals(3, familiesSynch.size());
assertEquals(11, CollectionTools.size(this.neighborhood.allMembers()));
assertEquals(11, membersSynch.size());
assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
jetsons.removeMember(jetsons.memberNamed("Judy"));
assertEquals(3, familiesSynch.size());
assertEquals(10, CollectionTools.size(this.neighborhood.allMembers()));
assertEquals(10, membersSynch.size());
assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
jetsons.addMember("Fido");
assertEquals(3, familiesSynch.size());
assertEquals(11, CollectionTools.size(this.neighborhood.allMembers()));
assertEquals(11, membersSynch.size());
assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
this.neighborhood.removeFamily(jetsons);
assertEquals(2, familiesSynch.size());
assertEquals(7, CollectionTools.size(this.neighborhood.allMembers()));
assertEquals(7, membersSynch.size());
assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
Family bears = this.neighborhood.addFamily("Bear");
bears.addMember("Yogi");
@@ -106,14 +106,14 @@ public class CompositeCollectionValueModelTests extends TestCase {
assertEquals(8, CollectionTools.size(this.neighborhood.allMembers()));
assertEquals(8, membersSynch.size());
assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
bears.addMember("Boo-Boo");
assertEquals(3, familiesSynch.size());
assertEquals(9, CollectionTools.size(this.neighborhood.allMembers()));
assertEquals(9, membersSynch.size());
assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
Neighborhood n2 = new Neighborhood("Hanna-Barbera 2");
this.neighborhoodHolder.setValue(n2);
@@ -122,7 +122,7 @@ public class CompositeCollectionValueModelTests extends TestCase {
assertEquals(12, CollectionTools.size(n2.allMembers()));
assertEquals(12, membersSynch.size());
assertEquals(CollectionTools.bag(n2.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.values()));
+ assertEquals(membersSynch, CollectionTools.bag((Iterator) compositeCVM.iterator()));
}
public void testNoTransformer() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java
index 3d7e87c383..c7a0e361f3 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java
@@ -24,7 +24,7 @@ import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
public class FilteringCollectionValueModelTests extends TestCase {
- private CollectionValueModel collectionHolder;
+ private SimpleCollectionValueModel collectionHolder;
CollectionChangeEvent addEvent;
CollectionChangeEvent removeEvent;
CollectionChangeEvent collectionClearedEvent;
@@ -67,31 +67,31 @@ public class FilteringCollectionValueModelTests extends TestCase {
super.tearDown();
}
- public void testValues() {
+ public void testIterator() {
// add a listener to "activate" the wrapper
this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
- assertEquals("foo", ((Iterator) this.collectionHolder.values()).next());
- assertFalse(((Iterator) this.filteredCollectionHolder.values()).hasNext());
+ assertEquals("foo", ((Iterator) this.collectionHolder.iterator()).next());
+ assertFalse(((Iterator) this.filteredCollectionHolder.iterator()).hasNext());
this.collectionHolder.add("bar");
- Iterator collectionHolderValue = (Iterator) this.collectionHolder.values();
+ Iterator collectionHolderValue = (Iterator) this.collectionHolder.iterator();
assertEquals("foo", collectionHolderValue.next());
assertEquals("bar", collectionHolderValue.next());
- assertTrue(((Iterator) this.filteredCollectionHolder.values()).hasNext());
- assertEquals("bar", ((Iterator) this.filteredCollectionHolder.values()).next());
+ assertTrue(((Iterator) this.filteredCollectionHolder.iterator()).hasNext());
+ assertEquals("bar", ((Iterator) this.filteredCollectionHolder.iterator()).next());
this.collectionHolder.remove("bar");
- assertEquals("foo", ((Iterator) this.collectionHolder.values()).next());
- assertFalse(((Iterator) this.filteredCollectionHolder.values()).hasNext());
+ assertEquals("foo", ((Iterator) this.collectionHolder.iterator()).next());
+ assertFalse(((Iterator) this.filteredCollectionHolder.iterator()).hasNext());
this.collectionHolder.remove("foo");
- assertFalse(((Iterator) this.collectionHolder.values()).hasNext());
- assertFalse(((Iterator) this.filteredCollectionHolder.values()).hasNext());
+ assertFalse(((Iterator) this.collectionHolder.iterator()).hasNext());
+ assertFalse(((Iterator) this.filteredCollectionHolder.iterator()).hasNext());
this.collectionHolder.add("foo");
- assertEquals("foo", ((Iterator) this.collectionHolder.values()).next());
- assertFalse(((Iterator) this.filteredCollectionHolder.values()).hasNext());
+ assertEquals("foo", ((Iterator) this.collectionHolder.iterator()).next());
+ assertFalse(((Iterator) this.filteredCollectionHolder.iterator()).hasNext());
}
public void testSetValue() {
@@ -102,12 +102,12 @@ public class FilteringCollectionValueModelTests extends TestCase {
newCollection.add("fox");
newCollection.add("baz");
- ((SimpleCollectionValueModel) this.collectionHolder).setValue(newCollection);
+ ((SimpleCollectionValueModel) this.collectionHolder).setCollection(newCollection);
- Iterator collectionValues = (Iterator) this.collectionHolder.values();
+ Iterator collectionValues = (Iterator) this.collectionHolder.iterator();
assertEquals("fox", collectionValues.next());
assertEquals("baz", collectionValues.next());
- Iterator filteredCollectionValues = (Iterator) this.filteredCollectionHolder.values();
+ Iterator filteredCollectionValues = (Iterator) this.filteredCollectionHolder.iterator();
assertEquals("baz", filteredCollectionValues.next());
assertFalse(filteredCollectionValues.hasNext());
}
@@ -186,7 +186,7 @@ public class FilteringCollectionValueModelTests extends TestCase {
newCollection.add("fox");
newCollection.add("baz");
- ((SimpleCollectionValueModel) this.collectionHolder).setValue(newCollection);
+ ((SimpleCollectionValueModel) this.collectionHolder).setCollection(newCollection);
this.verifyEvent(this.collectionChangedEvent, this.collectionHolder, new Vector());
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java
index 67ac3dfd6b..1e968b25d3 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java
@@ -67,7 +67,7 @@ public class ItemCollectionListValueModelAdapterTests extends TestCase {
}
public void testCollectionSynchronization() {
- CollectionValueModel collectionHolder = this.buildCollectionHolder();
+ SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
ListValueModel listValueModel = new ItemCollectionListValueModelAdapter(collectionHolder, Junk.STUFF_COLLECTION);
SynchronizedList synchList = new SynchronizedList(listValueModel);
assertEquals(6, synchList.size());
@@ -171,7 +171,7 @@ public class ItemCollectionListValueModelAdapterTests extends TestCase {
assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
}
- private CollectionValueModel buildCollectionHolder() {
+ private SimpleCollectionValueModel buildCollectionHolder() {
return new SimpleCollectionValueModel(this.buildCollection());
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java
index d214944204..a5319f499a 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java
@@ -67,7 +67,7 @@ public class ItemListListValueModelAdapterTests extends TestCase {
}
public void testCollectionSynchronization() {
- CollectionValueModel collectionHolder = this.buildCollectionHolder();
+ SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
ListValueModel listValueModel = new ItemListListValueModelAdapter(collectionHolder, Junk.STUFF_LIST);
SynchronizedList synchList = new SynchronizedList(listValueModel);
assertEquals(6, synchList.size());
@@ -171,7 +171,7 @@ public class ItemListListValueModelAdapterTests extends TestCase {
assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
}
- private CollectionValueModel buildCollectionHolder() {
+ private SimpleCollectionValueModel buildCollectionHolder() {
return new SimpleCollectionValueModel(this.buildCollection());
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java
index 65672860f5..cb7b62725d 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java
@@ -88,7 +88,7 @@ public class ItemPropertyListValueModelAdapterTests extends TestCase {
assertEquals(6, synchList.size());
this.compare(listValueModel, synchList);
- collectionHolder.setValue(this.buildCollection());
+ collectionHolder.setCollection(this.buildCollection());
assertEquals(6, synchList.size());
this.compare(listValueModel, synchList);
}
@@ -169,7 +169,7 @@ public class ItemPropertyListValueModelAdapterTests extends TestCase {
assertEquals(6, synchList.size());
this.compareSort(listValueModel, synchList, comparator);
- collectionHolder.setValue(this.buildCollection());
+ collectionHolder.setCollection(this.buildCollection());
assertEquals(6, synchList.size());
this.compareSort(listValueModel, synchList, comparator);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java
index 3d8d7716c7..ddc249e174 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java
@@ -68,7 +68,7 @@ public class ItemStateListValueModelAdapterTests extends TestCase {
}
public void testCollectionSynchronization() {
- CollectionValueModel collectionHolder = this.buildCollectionHolder();
+ SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
ListValueModel listValueModel = new ItemStateListValueModelAdapter(collectionHolder);
SynchronizedList synchList = new SynchronizedList(listValueModel);
assertEquals(6, synchList.size());
@@ -140,7 +140,7 @@ public class ItemStateListValueModelAdapterTests extends TestCase {
}
private void verifyCollectionSort(Comparator comparator) {
- CollectionValueModel collectionHolder = this.buildCollectionHolder();
+ SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
ListValueModel listValueModel = new ItemStateListValueModelAdapter(new SortedListValueModelAdapter(collectionHolder, comparator));
SynchronizedList synchList = new SynchronizedList(listValueModel);
assertEquals(6, synchList.size());
@@ -254,7 +254,7 @@ public class ItemStateListValueModelAdapterTests extends TestCase {
assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
}
- private CollectionValueModel buildCollectionHolder() {
+ private SimpleCollectionValueModel buildCollectionHolder() {
return new SimpleCollectionValueModel(this.buildCollection());
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java
index 3885b57eed..98ce3b8658 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java
@@ -55,7 +55,7 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
super.tearDown();
}
- public void testValues() {
+ public void testIterator() {
this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
public void itemsAdded(CollectionChangeEvent e) {
// override failure
@@ -64,7 +64,7 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
this.wrappedListHolder.add(0, "foo");
this.wrappedListHolder.add(1, "bar");
this.wrappedListHolder.add(2, "baz");
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(3, adapterCollection.size());
assertEquals(this.wrappedCollection(), adapterCollection);
}
@@ -77,17 +77,17 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
this.wrappedListHolder.add(0, "foo");
this.wrappedListHolder.add(1, "bar");
this.wrappedListHolder.add(2, "baz");
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(3, adapterCollection.size());
assertEquals(this.wrappedCollection(), adapterCollection);
this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(0, adapterCollection.size());
assertEquals(new HashBag(), adapterCollection);
this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(3, adapterCollection.size());
assertEquals(this.wrappedCollection(), adapterCollection);
}
@@ -104,7 +104,7 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
this.wrappedListHolder.add(5, "jaz");
assertEquals(6, this.wrappedList.size());
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(this.wrappedCollection(), adapterCollection);
assertEquals(this.wrappedCollection(), CollectionTools.collection(synchList.iterator()));
assertEquals(this.wrappedCollection(), synchCollection);
@@ -125,7 +125,7 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
assertFalse(this.wrappedList.contains("foo"));
assertEquals(4, this.wrappedList.size());
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(this.wrappedCollection(), adapterCollection);
assertEquals(this.wrappedCollection(), CollectionTools.collection(synchList.iterator()));
assertEquals(this.wrappedCollection(), synchCollection);
@@ -152,7 +152,7 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
assertFalse(this.wrappedList.contains("foo"));
assertEquals(4, this.wrappedList.size());
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(this.wrappedCollection(), adapterCollection);
}
@@ -168,12 +168,12 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
this.wrappedListHolder.add(0, "foo");
this.wrappedListHolder.add(1, "bar");
this.wrappedListHolder.add(2, "baz");
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(3, adapterCollection.size());
this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
public void itemsRemoved(CollectionChangeEvent e) {
assertEquals("foo", e.items().next());
- assertFalse(CollectionTools.contains((Iterator) ListCollectionValueModelAdapterTests.this.adapter.values(), "joo"));
+ assertFalse(CollectionTools.contains((Iterator) ListCollectionValueModelAdapterTests.this.adapter.iterator(), "joo"));
assertEquals(2, ListCollectionValueModelAdapterTests.this.adapter.size());
}
public void itemsAdded(CollectionChangeEvent e) {
@@ -182,7 +182,7 @@ public class ListCollectionValueModelAdapterTests extends TestCase {
}
});
this.wrappedListHolder.replace(0, "joo");
- adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(3, adapterCollection.size());
assertEquals(this.wrappedCollection(), adapterCollection);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java
index d01c5be2e4..7113451e42 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/NullCollectionValueModelTests.java
@@ -9,10 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.utility.tests.internal.model.value;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
import org.eclipse.jpt.utility.internal.model.value.CollectionValueModel;
import org.eclipse.jpt.utility.internal.model.value.NullCollectionValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
@@ -38,60 +34,12 @@ public class NullCollectionValueModelTests extends TestCase {
super.tearDown();
}
- public void testAdd() {
- boolean exCaught = false;
- try {
- this.collectionHolder.add("foo");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddAll() {
- boolean exCaught = false;
- Collection<String> items = new ArrayList<String>();
- items.add("foo");
- items.add("bar");
- items.add("baz");
- try {
- this.collectionHolder.addAll(items);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- try {
- this.collectionHolder.remove("foo");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveAll() {
- boolean exCaught = false;
- Collection<String> items = new ArrayList<String>();
- items.add("foo");
- items.add("bar");
- items.add("baz");
- try {
- this.collectionHolder.removeAll(items);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
public void testSize() {
assertEquals(0, this.collectionHolder.size());
}
- public void testValues() {
- assertFalse(((Iterator) this.collectionHolder.values()).hasNext());
+ public void testIterator() {
+ assertFalse(this.collectionHolder.iterator().hasNext());
}
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java
index c635335f65..dc837b5d67 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java
@@ -51,12 +51,12 @@ public class PropertyCollectionValueModelAdapterTests extends TestCase {
super.tearDown();
}
- public void testValues() {
+ public void testIterator() {
this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
public void itemsAdded(CollectionChangeEvent e) {/* OK */}
});
this.wrappedValueHolder.setValue("foo");
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection(this.adapter.iterator());
assertEquals(1, adapterCollection.size());
assertEquals(this.wrappedCollection(), adapterCollection);
assertEquals("foo", adapterCollection.iterator().next());
@@ -68,18 +68,18 @@ public class PropertyCollectionValueModelAdapterTests extends TestCase {
};
this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
this.wrappedValueHolder.setValue("foo");
- Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ Collection adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(1, adapterCollection.size());
assertEquals(this.wrappedCollection(), adapterCollection);
assertEquals("foo", adapterCollection.iterator().next());
this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(0, adapterCollection.size());
assertEquals(new HashBag(), adapterCollection);
this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection((Iterator) this.adapter.values());
+ adapterCollection = CollectionTools.collection((Iterator) this.adapter.iterator());
assertEquals(1, adapterCollection.size());
assertEquals(this.wrappedCollection(), adapterCollection);
assertEquals("foo", adapterCollection.iterator().next());
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ReadOnlyCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ReadOnlyCollectionValueModelTests.java
index 813198f1c1..fb90a5d551 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ReadOnlyCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/ReadOnlyCollectionValueModelTests.java
@@ -37,7 +37,7 @@ public class ReadOnlyCollectionValueModelTests extends TestCase {
private CollectionValueModel buildCollectionHolder() {
return new AbstractReadOnlyCollectionValueModel() {
- public Iterator values() {
+ public Iterator iterator() {
return ReadOnlyCollectionValueModelTests.collection();
}
};
@@ -67,8 +67,8 @@ public class ReadOnlyCollectionValueModelTests extends TestCase {
super.tearDown();
}
- public void testValues() {
- assertEquals(buildCollection(), CollectionTools.bag((Iterator) this.collectionHolder.values()));
+ public void testIterator() {
+ assertEquals(buildCollection(), CollectionTools.bag(this.collectionHolder.iterator()));
}
public void testSize() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java
index 599fc6a537..d1a994fb71 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java
@@ -24,11 +24,11 @@ import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
import org.eclipse.jpt.utility.tests.internal.TestTools;
public class SimpleCollectionValueModelTests extends TestCase {
- private CollectionValueModel bagHolder;
+ private SimpleCollectionValueModel bagHolder;
CollectionChangeEvent bagEvent;
String bagEventType;
- private CollectionValueModel setHolder;
+ private SimpleCollectionValueModel setHolder;
CollectionChangeEvent setEvent;
String setEventType;
@@ -88,34 +88,34 @@ public class SimpleCollectionValueModelTests extends TestCase {
super.tearDown();
}
- public void testValues() {
- assertEquals(this.buildBag(), CollectionTools.bag((Iterator) this.bagHolder.values()));
- assertEquals(this.buildSet(), CollectionTools.set((Iterator) this.setHolder.values()));
+ public void testIterator() {
+ assertEquals(this.buildBag(), CollectionTools.bag(this.bagHolder.iterator()));
+ assertEquals(this.buildSet(), CollectionTools.set(this.setHolder.iterator()));
}
public void testSize() {
- assertEquals(this.buildBag().size(), CollectionTools.size((Iterator) this.bagHolder.values()));
- assertEquals(this.buildSet().size(), CollectionTools.size((Iterator) this.setHolder.values()));
+ assertEquals(this.buildBag().size(), CollectionTools.size((Iterator) this.bagHolder.iterator()));
+ assertEquals(this.buildSet().size(), CollectionTools.size((Iterator) this.setHolder.iterator()));
}
private boolean bagHolderContains(Object item) {
- return CollectionTools.contains((Iterator) this.bagHolder.values(), item);
+ return CollectionTools.contains((Iterator) this.bagHolder.iterator(), item);
}
private boolean setHolderContains(Object item) {
- return CollectionTools.contains((Iterator) this.setHolder.values(), item);
+ return CollectionTools.contains((Iterator) this.setHolder.iterator(), item);
}
private boolean bagHolderContainsAll(Collection<String> items) {
- return CollectionTools.containsAll((Iterator) this.bagHolder.values(), items);
+ return CollectionTools.containsAll((Iterator) this.bagHolder.iterator(), items);
}
private boolean setHolderContainsAll(Collection<String> items) {
- return CollectionTools.containsAll((Iterator) this.setHolder.values(), items);
+ return CollectionTools.containsAll((Iterator) this.setHolder.iterator(), items);
}
private boolean bagHolderContainsAny(Collection<String> items) {
- Bag bag = CollectionTools.bag((Iterator) this.bagHolder.values());
+ Bag bag = CollectionTools.bag((Iterator) this.bagHolder.iterator());
for (String string : items) {
if (bag.contains(string)) {
return true;
@@ -125,7 +125,7 @@ public class SimpleCollectionValueModelTests extends TestCase {
}
private boolean setHolderContainsAny(Collection<String> items) {
- Set set = CollectionTools.set((Iterator) this.setHolder.values());
+ Set set = CollectionTools.set((Iterator) this.setHolder.iterator());
for (String string : items) {
if (set.contains(string)) {
return true;
@@ -192,10 +192,10 @@ public class SimpleCollectionValueModelTests extends TestCase {
assertFalse(this.setHolderContainsAny(this.buildRemoveItems()));
}
- public void testSetValue() {
+ public void testSetCollection() {
assertTrue(this.bagHolderContains("bar"));
assertFalse(this.bagHolderContains("jar"));
- ((SimpleCollectionValueModel) this.bagHolder).setValue(this.buildAddItems());
+ ((SimpleCollectionValueModel) this.bagHolder).setCollection(this.buildAddItems());
assertFalse(this.bagHolderContains("bar"));
assertTrue(this.bagHolderContains("jar"));
@@ -204,12 +204,12 @@ public class SimpleCollectionValueModelTests extends TestCase {
this.bagHolder.remove(null);
assertFalse(this.bagHolderContains(null));
- ((SimpleCollectionValueModel) this.bagHolder).setValue(null);
+ ((SimpleCollectionValueModel) this.bagHolder).setCollection(new HashBag());
assertFalse(this.bagHolderContains("jar"));
assertTrue(this.setHolderContains("bar"));
assertFalse(this.setHolderContains("jar"));
- ((SimpleCollectionValueModel) this.setHolder).setValue(this.buildAddItems());
+ ((SimpleCollectionValueModel) this.setHolder).setCollection(this.buildAddItems());
assertFalse(this.setHolderContains("bar"));
assertTrue(this.setHolderContains("jar"));
@@ -218,7 +218,7 @@ public class SimpleCollectionValueModelTests extends TestCase {
this.setHolder.remove(null);
assertFalse(this.setHolderContains(null));
- ((SimpleCollectionValueModel) this.setHolder).setValue(null);
+ ((SimpleCollectionValueModel) this.setHolder).setCollection(new HashBag());
assertFalse(this.setHolderContains("jar"));
}
@@ -276,7 +276,7 @@ public class SimpleCollectionValueModelTests extends TestCase {
this.bagEvent = null;
this.bagEventType = null;
- ((SimpleCollectionValueModel) this.bagHolder).setValue(this.buildBag());
+ ((SimpleCollectionValueModel) this.bagHolder).setCollection(this.buildBag());
this.verifyBagEvent(CHANGE);
this.bagEvent = null;
@@ -333,7 +333,7 @@ public class SimpleCollectionValueModelTests extends TestCase {
this.setEvent = null;
this.setEventType = null;
- ((SimpleCollectionValueModel) this.setHolder).setValue(this.buildSet());
+ ((SimpleCollectionValueModel) this.setHolder).setCollection(this.buildSet());
this.verifySetEvent(CHANGE);
this.setEvent = null;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java
index d15efb1340..0a7f89df2e 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java
@@ -33,7 +33,7 @@ import junit.framework.TestCase;
public class SortedListValueModelAdapterTests extends TestCase {
private SortedListValueModelAdapter adapter;
- private CollectionValueModel wrappedCollectionHolder;
+ private SimpleCollectionValueModel wrappedCollectionHolder;
private Collection wrappedCollection;
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SynchronizedBag.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SynchronizedBag.java
index 828dba8c38..f42a64b4a2 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SynchronizedBag.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/SynchronizedBag.java
@@ -124,7 +124,7 @@ class SynchronizedBag<E> implements Bag<E>, CollectionChangeListener {
public void collectionChanged(CollectionChangeEvent e) {
this.synchBag.clear();
- CollectionTools.addAll(this.synchBag, (Iterator) ((CollectionValueModel) e.getSource()).values());
+ CollectionTools.addAll(this.synchBag, (Iterator) ((CollectionValueModel) e.getSource()).iterator());
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
index 2c4fbecbcb..3faa9cd162 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
@@ -121,7 +121,7 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
this.expectedValues.clear();
this.nodeHolder.setValue(null);
this.verifyEvent(this.expectedValues);
- assertFalse(((Iterator) this.preferencesAdapter.values()).hasNext());
+ assertFalse(((Iterator) this.preferencesAdapter.iterator()).hasNext());
this.event = null;
this.nodeHolder.setValue(this.testNode);
@@ -253,7 +253,7 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
private void verifyAdapter(PreferencesCollectionValueModel cvm) {
assertEquals(this.expectedValues.size(), cvm.size());
- this.verifyItems(this.expectedValues, (Iterator) cvm.values());
+ this.verifyItems(this.expectedValues, (Iterator) cvm.iterator());
}
private void verifyItems(Map expected, Iterator stream) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
index abc8bea102..a92f24f833 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
@@ -51,7 +51,7 @@ public class ListModelAdapterTests extends TestCase {
}
public void testCollectionSynchronization() {
- CollectionValueModel collectionHolder = this.buildCollectionHolder();
+ SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
ListModel listModel = new ListModelAdapter(collectionHolder);
SynchronizedList synchList = new SynchronizedList(listModel);
assertEquals(6, synchList.size());
@@ -149,7 +149,7 @@ public class ListModelAdapterTests extends TestCase {
}
private void verifyCollectionSort(Comparator comparator) {
- CollectionValueModel collectionHolder = this.buildCollectionHolder();
+ SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
ListModel listModel = new ListModelAdapter(new SortedListValueModelAdapter(collectionHolder, comparator));
SynchronizedList synchList = new SynchronizedList(listModel);
assertEquals(6, synchList.size());
@@ -251,7 +251,7 @@ public class ListModelAdapterTests extends TestCase {
assertTrue(hasListeners);
}
- private CollectionValueModel buildCollectionHolder() {
+ private SimpleCollectionValueModel buildCollectionHolder() {
return new SimpleCollectionValueModel(this.buildCollection());
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
index 146757de5e..d8638c4586 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
@@ -88,7 +88,7 @@ import org.eclipse.jpt.utility.tests.internal.model.value.swing.TableModelAdapte
* list value model (the sorted people adapter)
*/
public class TableModelAdapterUITest {
- private CollectionValueModel eyeColorsHolder;
+ private SimpleCollectionValueModel eyeColorsHolder;
private PropertyValueModel crowdHolder;
private PropertyValueModel selectedPersonHolder;
private ListValueModel sortedPeopleAdapter;
@@ -116,7 +116,7 @@ public class TableModelAdapterUITest {
this.openWindow();
}
- private CollectionValueModel buildEyeColorCollectionHolder() {
+ private SimpleCollectionValueModel buildEyeColorCollectionHolder() {
return new SimpleCollectionValueModel(Person.getValidEyeColors());
}
@@ -443,7 +443,7 @@ public class TableModelAdapterUITest {
}
if ((eyeColor.length() == 0)) {
JOptionPane.showMessageDialog(null, "The eye color is required.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
- } else if (CollectionTools.contains((Iterator) this.eyeColorsHolder.values(), eyeColor)) {
+ } else if (CollectionTools.contains((Iterator) this.eyeColorsHolder.iterator(), eyeColor)) {
JOptionPane.showMessageDialog(null, "The eye color already exists.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
} else {
return eyeColor;

Back to the top