Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/JpaContextNode.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobCommand.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ListenerList.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBag.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java284
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java323
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java190
-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/CompositeCollectionValueModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositePropertyValueModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelWrapper.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java10
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java30
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java8
26 files changed, 539 insertions, 385 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/JpaContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/JpaContextNode.java
index 9d73a5d648..7309add00d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/JpaContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/JpaContextNode.java
@@ -51,9 +51,14 @@ public interface JpaContextNode
Catalog getContextDefaultDbCatalog();
Schema getContextDefaultDbSchema();
-
+
/**
- * Called after the update is called.
+ * "Post update" is called once the JPA project "update" is complete.
+ * We use this to calculate (typically default) state that is dependent
+ * on the entity inheritance hierarchy (e.g. discriminator column name).
+ * Of course, if these settings change, yet another "update" will be
+ * triggered, followed by yet another "post update"; until the JPA
+ * project's state quiesces
*/
void postUpdate();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
index bfba2199b2..0246ceb8a9 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
@@ -1097,8 +1097,8 @@ public abstract class AbstractJavaEntity
@Override
public void postUpdate() {
super.postUpdate();
- postUpdateDiscriminatorColumn();
- postUpdateDiscriminatorValue();
+ this.postUpdateDiscriminatorColumn();
+ this.postUpdateDiscriminatorValue();
this.associationOverrideContainer.postUpdate();
}
@@ -1157,7 +1157,7 @@ public abstract class AbstractJavaEntity
protected void postUpdateDiscriminatorColumn() {
this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
- getDiscriminatorColumn().postUpdate();
+ this.getDiscriminatorColumn().postUpdate();
}
protected void updateDiscriminatorValue(DiscriminatorValueAnnotation discriminatorValueResource) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java
index b2c5c3d861..7a4eac810e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java
@@ -1288,9 +1288,8 @@ public abstract class AbstractOrmEntity
@Override
public void postUpdate() {
super.postUpdate();
- this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
- getDiscriminatorColumn().postUpdate();
- postUpdateDiscriminatorValue();
+ this.postUpdateDiscriminatorColumn();
+ this.postUpdateDiscriminatorValue();
}
protected String buildDefaultName() {
@@ -1314,7 +1313,7 @@ public abstract class AbstractOrmEntity
protected void postUpdateDiscriminatorColumn() {
this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
- getDiscriminatorColumn().postUpdate();
+ this.getDiscriminatorColumn().postUpdate();
}
protected void updateDiscriminatorValue() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java
index 90217eafa2..50c93e70e1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java
@@ -183,8 +183,8 @@ public class GenericJavaDiscriminatorColumn extends AbstractJavaNamedColumn<Disc
public void postUpdate() {
super.postUpdate();
this.setDefaultName(this.buildDefaultName());
- this.setDefaultLength(this.buildDefaultLength());
this.setDefaultDiscriminatorType(this.buildDefaultDiscriminatorType());
+ this.setDefaultLength(this.buildDefaultLength());
}
protected DiscriminatorType getResourceDiscriminatorType(DiscriminatorColumnAnnotation discriminatorColumn) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobCommand.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobCommand.java
index d9acc01602..f4b1a0d7d0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobCommand.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobCommand.java
@@ -30,6 +30,11 @@ public interface JobCommand {
/**
* Execute the command. The semantics of the command
* is determined by the contract between the client and server.
+ * The command should check, as appropriate, whether the specified progress
+ * monitor is {@link IProgressMonitor#isCanceled() "canceled"}; if it is,
+ * the command should throw an
+ * {@link org.eclipse.core.runtime.OperationCanceledException OperationCanceledException}.
+ * @see IProgressMonitor#isCanceled()
*/
IStatus execute(IProgressMonitor monitor);
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java
index 2b792e2857..3bdf8b0b6d 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java
@@ -32,7 +32,7 @@ import java.util.NoSuchElementException;
* important not to set the initial capacity too high (or the load factor too
* low) if iteration performance is important.
* <p>
- * <b>Note that this implementation is not synchronized.</b> If multiple
+ * <strong>Note that this implementation is not synchronized.</strong> If multiple
* threads access a bag concurrently, and at least one of the threads modifies
* the bag, it <em>must</em> be synchronized externally. This is typically
* accomplished by synchronizing on some object that naturally encapsulates
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java
index 4903d6f0a4..82a65a9e88 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IdentityHashBag.java
@@ -26,14 +26,14 @@ import java.util.NoSuchElementException;
* and <code>o2</code> are considered equal if and only if
* <code>(o1 == null ? o2 == null : o1.equals(o2))</code>.)
* <p>
- * <b>
+ * <strong>
* This class is <em>not</em> a general-purpose {@link Bag}
* implementation! While this class implements the {@link Bag} interface, it
* intentionally violates {@link Bag}'s general contract, which mandates the
* use of the <code>equals</code> method when comparing objects. This class is
* designed for use only in the rare cases wherein object-identity
* semantics are required.
- * </b>
+ * </strong>
* <p>
* This class makes no guarantees as to the iteration order of
* the bag's elements; in particular, it does not guarantee that the order
@@ -50,7 +50,7 @@ import java.util.NoSuchElementException;
* important not to set the initial capacity too high (or the load factor too
* low) if iteration performance is important.
* <p>
- * <b>Note that this implementation is not synchronized.</b> If multiple
+ * <strong>Note that this implementation is not synchronized.</strong> If multiple
* threads access a bag concurrently, and at least one of the threads modifies
* the bag, it <em>must</em> be synchronized externally. This is typically
* accomplished by synchronizing on some object that naturally encapsulates
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ListenerList.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ListenerList.java
index ff194fcaa9..e93b78ccd7 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ListenerList.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ListenerList.java
@@ -17,6 +17,8 @@ import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.EventListener;
+import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
+
/**
* Maintain a thread-safe list of listeners that does not allow adding
* duplicate listeners or removing non-listeners.
@@ -24,6 +26,10 @@ import java.util.EventListener;
public class ListenerList<L extends EventListener>
implements Serializable
{
+ /**
+ * We can mark this volatile and not synchronize the read methods because
+ * we never change the <em>contents</em> of the array.
+ */
private transient volatile L[] listeners;
private static final long serialVersionUID = 1L;
@@ -58,8 +64,8 @@ public class ListenerList<L extends EventListener>
/**
* Return the listeners.
*/
- public L[] getListeners() {
- return this.listeners;
+ public Iterable<L> getListeners() {
+ return new ArrayIterable<L>(this.listeners);
}
/**
@@ -112,6 +118,14 @@ public class ListenerList<L extends EventListener>
this.listeners = ArrayTools.clear(this.listeners);
}
+ /**
+ * Return the type of listeners held by the listener list.
+ */
+ @SuppressWarnings("unchecked")
+ public Class<L> getListenerType() {
+ return (Class<L>) this.listeners.getClass().getComponentType();
+ }
+
@Override
public String toString() {
return Arrays.toString(this.listeners);
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBag.java
index 5538a0ed2d..e59e8a1085 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBag.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBag.java
@@ -20,7 +20,7 @@ public class SynchronizedBag<E>
implements Bag<E>, Serializable
{
/** Backing bag. */
- private Bag<E> bag;
+ private final Bag<E> bag;
/** Object to synchronize on. */
private final Object mutex;
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java
index 6986617a02..cc4b656752 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedBoolean.java
@@ -15,14 +15,15 @@ import org.eclipse.jpt.utility.Command;
/**
* This class provides synchronized access to a <code>boolean</code> value.
* It also provides protocol for suspending a thread until the
- * boolean value is set to true or false, with optional time-outs.
+ * <code>boolean</code> value is set to <code>true</code> or <code>false</code>,
+ * with optional time-outs.
*
* @see BooleanHolder
*/
public class SynchronizedBoolean
implements Cloneable, Serializable
{
- /** Backing boolean. */
+ /** Backing <code>boolean</code>. */
private boolean value;
/** Object to synchronize on. */
@@ -34,8 +35,8 @@ public class SynchronizedBoolean
// ********** constructors **********
/**
- * Create a synchronized <code>boolean</code> with the specified initial value
- * and mutex.
+ * Create a synchronized <code>boolean</code> with the specified
+ * initial value and mutex.
*/
public SynchronizedBoolean(boolean value, Object mutex) {
super();
@@ -44,7 +45,9 @@ public class SynchronizedBoolean
}
/**
- * Create a synchronized <code>boolean</code> with the specified initial value.
+ * Create a synchronized <code>boolean</code> with the
+ * specified initial value.
+ * The synchronized <code>boolean</code> itself will be the mutex.
*/
public SynchronizedBoolean(boolean value) {
super();
@@ -53,7 +56,8 @@ public class SynchronizedBoolean
}
/**
- * Create a synchronized <code>boolean</code> with an initial value of <code>false</code>
+ * Create a synchronized <code>boolean</code>
+ * with an initial value of <code>false</code>
* and specified mutex.
*/
public SynchronizedBoolean(Object mutex) {
@@ -61,7 +65,9 @@ public class SynchronizedBoolean
}
/**
- * Create a synchronized <code>boolean</code> with an initial value of <code>false</code>.
+ * Create a synchronized <code>boolean</code>
+ * with an initial value of <code>false</code>.
+ * The synchronized <code>boolean</code> itself will be the mutex.
*/
public SynchronizedBoolean() {
this(false);
@@ -71,7 +77,7 @@ public class SynchronizedBoolean
// ********** accessors **********
/**
- * Return the current boolean value.
+ * Return the current <code>boolean</code> value.
*/
public boolean getValue() {
synchronized (this.mutex) {
@@ -80,7 +86,8 @@ public class SynchronizedBoolean
}
/**
- * Return whether the current boolean value is true.
+ * Return whether the current <code>boolean</code>
+ * value is <code>true</code>.
*/
public boolean isTrue() {
synchronized (this.mutex) {
@@ -89,7 +96,8 @@ public class SynchronizedBoolean
}
/**
- * Return whether the current boolean value is false.
+ * Return whether the current <code>boolean</code>
+ * value is <code>false</code>.
*/
public boolean isFalse() {
synchronized (this.mutex) {
@@ -98,7 +106,8 @@ public class SynchronizedBoolean
}
/**
- * Return whether the current boolean value is the specified value.
+ * Return whether the current <code>boolean</code>
+ * value is the specified value.
*/
public boolean is(boolean v) {
synchronized (this.mutex) {
@@ -107,36 +116,39 @@ public class SynchronizedBoolean
}
/**
- * Set the boolean value. If the value changes, all waiting
- * threads are notified.
+ * Set the <code>boolean</code> value.
+ * If the value changes, all waiting threads are notified.
*/
public void setValue(boolean value) {
synchronized (this.mutex) {
- if (this.value != value) {
- this.value = value;
- this.mutex.notifyAll();
- }
+ this.setValue_(value);
}
}
/**
- * Set the boolean value to true. If the value changes, all waiting
- * threads are notified.
+ * Pre-condition: synchronized
*/
- public void setTrue() {
- synchronized (this.mutex) {
- this.setValue(true);
+ private void setValue_(boolean value) {
+ if (this.value != value) {
+ this.value = value;
+ this.mutex.notifyAll();
}
}
/**
- * Set the boolean value to false. If the value changes, all waiting
- * threads are notified.
+ * Set the <code>boolean</code> value to <code>true</code>.
+ * If the value changes, all waiting threads are notified.
+ */
+ public void setTrue() {
+ this.setValue(true);
+ }
+
+ /**
+ * Set the <code>boolean</code> value to <code>false</code>.
+ * If the value changes, all waiting threads are notified.
*/
public void setFalse() {
- synchronized (this.mutex) {
- this.setValue(false);
- }
+ this.setValue(false);
}
/**
@@ -151,176 +163,196 @@ public class SynchronizedBoolean
// ********** indefinite waits **********
/**
- * Suspend the current thread until the boolean value changes
- * to the specified value. If the boolean value is already the
+ * Suspend the current thread until the <code>boolean</code> value changes
+ * to the specified value. If the <code>boolean</code> value is already the
* specified value, return immediately.
*/
public void waitUntilValueIs(boolean v) throws InterruptedException {
synchronized (this.mutex) {
- while (this.value != v) {
- this.mutex.wait();
- }
+ this.waitUntilValueIs_(v);
}
}
/**
- * Suspend the current thread until the boolean value changes to true.
- * If the boolean value is already true, return immediately.
+ * Pre-condition: synchronized
*/
- public void waitUntilTrue() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs(true);
+ private void waitUntilValueIs_(boolean v) throws InterruptedException {
+ while (this.value != v) {
+ this.mutex.wait();
}
}
/**
- * Suspend the current thread until the boolean value changes to false.
- * If the boolean value is already false, return immediately.
+ * Suspend the current thread until the <code>boolean</code> value
+ * changes to <code>true</code>.
+ * If the <code>boolean</code> value is already <code>true</code>,
+ * return immediately.
+ */
+ public void waitUntilTrue() throws InterruptedException {
+ this.waitUntilValueIs(true);
+ }
+
+ /**
+ * Suspend the current thread until the <code>boolean</code> value
+ * changes to <code>false</code>.
+ * If the <code>boolean</code> value is already <code>false</code>,
+ * return immediately.
*/
public void waitUntilFalse() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs(false);
- }
+ this.waitUntilValueIs(false);
}
/**
- * Suspend the current thread until the boolean value changes to
- * NOT the specified value, then change it back to the specified
- * value and continue executing. If the boolean value is already
- * NOT the specified value, set the value to the specified value
+ * Suspend the current thread until the <code>boolean</code> value changes to
+ * <em>not</em> the specified value, then change it back to the specified
+ * value and continue executing. If the <code>boolean</code> value is already
+ * <em>not</em> the specified value, set the value to the specified value
* immediately.
*/
public void waitToSetValue(boolean v) throws InterruptedException {
synchronized (this.mutex) {
- this.waitUntilValueIs( ! v);
- this.setValue(v);
+ this.waitUntilValueIs_( ! v);
+ this.setValue_(v);
}
}
/**
- * Suspend the current thread until the boolean value changes to false,
- * then change it back to true and continue executing. If the boolean
- * value is already false, set the value to true immediately.
+ * Suspend the current thread until the <code>boolean</code> value
+ * changes to <code>false</code>,
+ * then change it back to <code>true</code> and continue executing.
+ * If the <code>boolean</code> value is already <code>false</code>,
+ * set the value to <code>true</code> immediately.
*/
public void waitToSetTrue() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitToSetValue(true);
- }
+ this.waitToSetValue(true);
}
/**
- * Suspend the current thread until the boolean value changes to true,
- * then change it back to false and continue executing. If the boolean
- * value is already true, set the value to false immediately.
+ * Suspend the current thread until the <code>boolean</code> value
+ * changes to <code>true</code>,
+ * then change it back to <code>false</code> and continue executing.
+ * If the <code>boolean</code> value is already <code>true</code>,
+ * set the value to <code>false</code> immediately.
*/
public void waitToSetFalse() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitToSetValue(false);
- }
+ this.waitToSetValue(false);
}
// ********** timed waits **********
/**
- * Suspend the current thread until the boolean value changes
+ * Suspend the current thread until the <code>boolean</code> value changes
* to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the boolean value is already the specified value, return true
- * immediately.
+ * The time-out is specified in milliseconds. Return <code>true</code> if the specified
+ * value was achieved; return <code>false</code> if a time-out occurred.
+ * If the <code>boolean</code> value is already the specified value,
+ * return <code>true</code> immediately.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitUntilValueIs(boolean v, long timeout) throws InterruptedException {
synchronized (this.mutex) {
- if (timeout == 0L) {
- this.waitUntilValueIs(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value != v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value == v);
+ return this.waitUntilValueIs_(v, timeout);
}
}
/**
- * Suspend the current thread until the boolean value changes
- * to true or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the boolean value is already true, return true immediately.
+ * Pre-condition: synchronized
*/
- public boolean waitUntilTrue(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs(true, timeout);
+ private boolean waitUntilValueIs_(boolean v, long timeout) throws InterruptedException {
+ if (timeout == 0L) {
+ this.waitUntilValueIs_(v); // wait indefinitely until notified
+ return true; // if it ever comes back, the condition was met
}
+
+ long stop = System.currentTimeMillis() + timeout;
+ long remaining = timeout;
+ while ((this.value != v) && (remaining > 0L)) {
+ this.mutex.wait(remaining);
+ remaining = stop - System.currentTimeMillis();
+ }
+ return (this.value == v);
}
/**
- * Suspend the current thread until the boolean value changes
- * to false or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the boolean value is already true, return true immediately.
+ * Suspend the current thread until the <code>boolean</code> value changes
+ * to <code>true</code> or the specified time-out occurs.
+ * The time-out is specified in milliseconds. Return <code>true</code> if the specified
+ * value was achieved; return <code>false</code> if a time-out occurred.
+ * If the <code>boolean</code> value is already <code>true</code>,
+ * return <code>true</code> immediately.
+ * If the time-out is zero, wait indefinitely.
+ */
+ public boolean waitUntilTrue(long timeout) throws InterruptedException {
+ return this.waitUntilValueIs(true, timeout);
+ }
+
+ /**
+ * Suspend the current thread until the <code>boolean</code> value changes
+ * to <code>false</code> or the specified time-out occurs.
+ * The time-out is specified in milliseconds. Return <code>true</code> if the specified
+ * value was achieved; return <code>false</code> if a time-out occurred.
+ * If the <code>boolean</code> value is already <code>true</code>,
+ * return <code>true</code> immediately.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitUntilFalse(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs(false, timeout);
- }
+ return this.waitUntilValueIs(false, timeout);
}
/**
- * Suspend the current thread until the boolean value changes to NOT the
- * specified value, then change it back to the specified value and continue
- * executing. If the boolean value does not change to false before the
- * time-out, simply continue executing without changing the value.
- * The time-out is specified in milliseconds. Return true if the value was
- * set to the specified value; return false if a time-out occurred.
- * If the boolean value is already NOT the specified value, set the value
- * to the specified value immediately and return true.
+ * Suspend the current thread until the <code>boolean</code> value changes
+ * to <em>not</em> the specified value, then change it back to the specified
+ * value and continue executing. If the <code>boolean</code> value does not
+ * change to <code>false</code> before the time-out, simply continue
+ * executing without changing the value.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the value was set to the specified value; return <code>false</code>
+ * if a time-out occurred. If the <code>boolean</code> value is already
+ * <em>not</em> the specified value, set the value to the specified value
+ * immediately and return <code>true</code>.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitToSetValue(boolean v, long timeout) throws InterruptedException {
synchronized (this.mutex) {
- boolean success = this.waitUntilValueIs( ! v, timeout);
+ boolean success = this.waitUntilValueIs_( ! v, timeout);
if (success) {
- this.setValue(v);
+ this.setValue_(v);
}
return success;
}
}
/**
- * Suspend the current thread until the boolean value changes to false,
- * then change it back to true and continue executing. If the boolean
- * value does not change to false before the time-out, simply continue
- * executing without changing the value. The time-out is specified in
- * milliseconds. Return true if the value was set to true; return false
- * if a time-out occurred. If the boolean value is already false, set the
- * value to true immediately and return true.
+ * Suspend the current thread until the <code>boolean</code> value changes
+ * to <code>false</code>, then change it back to <code>true</code> and
+ * continue executing. If the <code>boolean</code> value does not change to
+ * <code>false</code> before the time-out, simply continue executing without
+ * changing the value. The time-out is specified in milliseconds. Return
+ * <code>true</code> if the value was set to <code>true</code>;
+ * return <code>false</code> if a time-out occurred. If the
+ * <code>boolean</code> value is already <code>false</code>, set the
+ * value to <code>true</code> immediately and return <code>true</code>.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitToSetTrue(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitToSetValue(true, timeout);
- }
+ return this.waitToSetValue(true, timeout);
}
/**
- * Suspend the current thread until the boolean value changes to true,
- * then change it back to false and continue executing. If the boolean
- * value does not change to true before the time-out, simply continue
- * executing without changing the value. The time-out is specified in
- * milliseconds. Return true if the value was set to false; return false
- * if a time-out occurred. If the boolean value is already true, set the
- * value to false immediately and return true.
+ * Suspend the current thread until the <code>boolean</code> value changes
+ * to <code>true</code>, then change it back to <code>false</code> and
+ * continue executing. If the <code>boolean</code> value does not change to
+ * <code>true</code> before the time-out, simply continue executing without
+ * changing the value. The time-out is specified in milliseconds. Return
+ * <code>true</code> if the value was set to <code>false</code>;
+ * return <code>false</code> if a time-out occurred. If the
+ * <code>boolean</code> value is already <code>true</code>, set the
+ * value to <code>false</code> immediately and return <code>true</code>.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitToSetFalse(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitToSetValue(false, timeout);
- }
+ return this.waitToSetValue(false, timeout);
}
@@ -328,7 +360,7 @@ public class SynchronizedBoolean
/**
* If the current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the value in another
+ * with the mutex locked. This is useful for initializing the value from another
* thread.
*/
public void execute(Command command) throws InterruptedException {
@@ -344,10 +376,10 @@ public class SynchronizedBoolean
// ********** standard methods **********
@Override
- public Object clone() {
+ public SynchronizedBoolean clone() {
try {
synchronized (this.mutex) {
- return super.clone();
+ return (SynchronizedBoolean) super.clone();
}
} catch (CloneNotSupportedException ex) {
throw new InternalError();
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java
index c5017d7e7d..122664ee5f 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedObject.java
@@ -13,15 +13,20 @@ import java.io.Serializable;
import org.eclipse.jpt.utility.Command;
/**
- * This class provides synchronized access to an object of type T.
+ * This class provides synchronized access to an object of type <code>V</code>.
* It also provides protocol for suspending a thread until the
- * value is set to null or a non-null value, with optional time-outs.
+ * value is set to <code>null</code> or a non-<code>null</code> value,
+ * with optional time-outs.
+ *
+ * @parm V the type of the synchronized object's value
*/
-public class SynchronizedObject<T>
+public class SynchronizedObject<V>
implements Cloneable, Serializable
{
- /** Backing value. */
- private T value;
+ /**
+ * Backing value.
+ */
+ private V value;
/** Object to synchronize on. */
private final Object mutex;
@@ -35,7 +40,7 @@ public class SynchronizedObject<T>
* Create a synchronized object with the specified initial value
* and mutex.
*/
- public SynchronizedObject(T value, Object mutex) {
+ public SynchronizedObject(V value, Object mutex) {
super();
this.value = value;
this.mutex = mutex;
@@ -43,8 +48,9 @@ public class SynchronizedObject<T>
/**
* Create a synchronized object with the specified initial value.
+ * The synchronized object itself will be the mutex.
*/
- public SynchronizedObject(T value) {
+ public SynchronizedObject(V value) {
super();
this.value = value;
this.mutex = this;
@@ -52,6 +58,7 @@ public class SynchronizedObject<T>
/**
* Create a synchronized object with an initial value of null.
+ * The synchronized object itself will be the mutex.
*/
public SynchronizedObject() {
this(null);
@@ -63,7 +70,7 @@ public class SynchronizedObject<T>
/**
* Return the current value.
*/
- public T getValue() {
+ public V getValue() {
synchronized (this.mutex) {
return this.value;
}
@@ -89,29 +96,53 @@ public class SynchronizedObject<T>
/**
* Set the value. If the value changes, all waiting
- * threads are notified.
+ * threads are notified. Return the previous value.
*/
- public void setValue(T value) {
+ public V setValue(V value) {
synchronized (this.mutex) {
- if (this.value != value) {
- this.value = value;
- this.mutex.notifyAll();
- }
+ return this.setValue_(value);
+ }
+ }
+
+ /**
+ * Pre-condition: synchronized
+ */
+ private V setValue_(V v) {
+ V old = this.value;
+ if (this.value != v) {
+ this.value = v;
+ this.mutex.notifyAll();
}
+ return old;
+ }
+
+ /**
+ * Set the value to <code>null</code>. If the value changes, all waiting
+ * threads are notified. Return the previous value.
+ */
+ public V setNull() {
+ return this.setValue(null);
}
/**
- * Set the value to null. If the value changes, all waiting
- * threads are notified.
+ * If the current value is the specified expected value, set it to the
+ * specified new value. Return the previous value.
*/
- public void setNull() {
+ public V compareAndSwap(V expectedValue, V newValue) {
synchronized (this.mutex) {
- this.setValue(null);
+ return this.compareAndSwap_(expectedValue, newValue);
}
}
/**
- * Return the object this object locks on while performing
+ * Pre-condition: synchronized
+ */
+ private V compareAndSwap_(V expectedValue, V newValue) {
+ return (this.value == expectedValue) ? this.setValue_(newValue) : this.value;
+ }
+
+ /**
+ * Return the object the synchronized object locks on while performing
* its operations.
*/
public Object getMutex() {
@@ -126,72 +157,99 @@ public class SynchronizedObject<T>
* to the specified value. If the value is already the
* specified value, return immediately.
*/
- public void waitUntilValueIs(T v) throws InterruptedException {
+ public void waitUntilValueIs(V v) throws InterruptedException {
synchronized (this.mutex) {
- while (this.value != v) {
- this.mutex.wait();
- }
+ this.waitUntilValueIs_(v);
+ }
+ }
+
+ /**
+ * Pre-condition: synchronized
+ */
+ private void waitUntilValueIs_(V v) throws InterruptedException {
+ while (this.value != v) {
+ this.mutex.wait();
}
}
/**
* Suspend the current thread until the value changes
* to something other than the specified value. If the
- * value is already NOT the specified value, return immediately.
+ * value is already <em>not</em> the specified value,
+ * return immediately.
*/
- public void waitUntilValueIsNot(T v) throws InterruptedException {
+ public void waitUntilValueIsNot(V v) throws InterruptedException {
synchronized (this.mutex) {
- while (this.value == v) {
- this.mutex.wait();
- }
+ this.waitUntilValueIsNot_(v);
}
}
/**
- * Suspend the current thread until the value changes to null.
- * If the value is already null, return immediately.
+ * Pre-condition: synchronized
*/
- public void waitUntilNull() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs(null);
+ private void waitUntilValueIsNot_(V v) throws InterruptedException {
+ while (this.value == v) {
+ this.mutex.wait();
}
}
/**
+ * Suspend the current thread until the value changes to <code>null</code>.
+ * If the value is already <code>null</code>, return immediately.
+ */
+ public void waitUntilNull() throws InterruptedException {
+ this.waitUntilValueIs(null);
+ }
+
+ /**
* Suspend the current thread until the value changes
- * to something other than null.
- * If the value is already NOT null, return immediately.
+ * to something other than <code>null</code>.
+ * If the value is already <em>not</em> <code>null</code>,
+ * return immediately.
*/
public void waitUntilNotNull() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIsNot(null);
- }
+ this.waitUntilValueIsNot(null);
}
/**
* Suspend the current thread until the value changes to
* something other than the specified value, then change
* it back to the specified value and continue executing.
- * If the value is already NOT the specified value, set
+ * If the value is already <em>not</em> the specified value, set
* the value immediately.
+ * Return the previous value.
*/
- public void waitToSetValue(T v) throws InterruptedException {
+ public V waitToSetValue(V v) throws InterruptedException {
synchronized (this.mutex) {
- this.waitUntilValueIsNot(v);
- this.setValue(v);
+ this.waitUntilValueIsNot_(v);
+ return this.setValue_(v);
}
}
/**
* Suspend the current thread until the value changes to
- * something other than null, then change it back to null
- * and continue executing. If the value is already NOT null,
- * set the value to null immediately.
+ * something other than <code>null</code>, then change it
+ * back to <code>null</code> and continue executing.
+ * If the value is already <em>not</em> <code>null</code>,
+ * set the value to <code>null</code> immediately.
+ * Return the previous value.
+ */
+ public V waitToSetNull() throws InterruptedException {
+ return this.waitToSetValue(null);
+ }
+
+ /**
+ * Suspend the current thread until the value changes to
+ * the specified expected value, then change it
+ * to the specified new value and continue executing.
+ * If the value is already the specified expected value,
+ * set the value to the specified new value immediately.
+ * Return the previous value.
*/
- public void waitToSetNull() throws InterruptedException {
+ public V waitToSwap(V expectedValue, V newValue) throws InterruptedException {
synchronized (this.mutex) {
- this.waitUntilNotNull();
- this.setValue(null);
+ this.waitUntilValueIs_(expectedValue);
+ return this.setValue_(newValue);
}
}
@@ -201,75 +259,93 @@ public class SynchronizedObject<T>
/**
* Suspend the current thread until the value changes
* to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the specified value was achieved; return <code>false</code>
+ * if a time-out occurred.
* If the value is already the specified value, return true immediately.
+ * If the time-out is zero, wait indefinitely.
*/
- public boolean waitUntilValueIs(T v, long timeout) throws InterruptedException {
+ public boolean waitUntilValueIs(V v, long timeout) throws InterruptedException {
synchronized (this.mutex) {
- if (timeout == 0L) {
- this.waitUntilValueIs(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
+ return this.waitUntilValueIs_(v, timeout);
+ }
+ }
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value != v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value == v);
+ /**
+ * Pre-condition: synchronized
+ */
+ private boolean waitUntilValueIs_(V v, long timeout) throws InterruptedException {
+ if (timeout == 0L) {
+ this.waitUntilValueIs_(v); // wait indefinitely until notified
+ return true; // if it ever comes back, the condition was met
}
+
+ long stop = System.currentTimeMillis() + timeout;
+ long remaining = timeout;
+ while ((this.value != v) && (remaining > 0L)) {
+ this.mutex.wait(remaining);
+ remaining = stop - System.currentTimeMillis();
+ }
+ return (this.value == v);
}
/**
* Suspend the current thread until the value changes to something
* other than the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was removed; return false if a time-out occurred.
- * If the value is already NOT the specified value, return true immediately.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the specified value was removed; return <code>false</code> if a
+ * time-out occurred. If the value is already <em>not</em> the specified
+ * value, return <code>true</code> immediately.
+ * If the time-out is zero, wait indefinitely.
*/
- public boolean waitUntilValueIsNot(T v, long timeout) throws InterruptedException {
+ public boolean waitUntilValueIsNot(V v, long timeout) throws InterruptedException {
synchronized (this.mutex) {
- if (timeout == 0L) {
- this.waitUntilValueIsNot(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
+ return this.waitUntilValueIsNot_(v, timeout);
+ }
+ }
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value == v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value != v);
+ /**
+ * Pre-condition: synchronized
+ */
+ private boolean waitUntilValueIsNot_(V v, long timeout) throws InterruptedException {
+ if (timeout == 0L) {
+ this.waitUntilValueIsNot_(v); // wait indefinitely until notified
+ return true; // if it ever comes back, the condition was met
}
+
+ long stop = System.currentTimeMillis() + timeout;
+ long remaining = timeout;
+ while ((this.value == v) && (remaining > 0L)) {
+ this.mutex.wait(remaining);
+ remaining = stop - System.currentTimeMillis();
+ }
+ return (this.value != v);
}
/**
* Suspend the current thread until the value changes
- * to null or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the value is already null, return true immediately.
+ * to <code>null</code> or the specified time-out occurs.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the specified value was achieved; return <code>false</code>
+ * if a time-out occurred. If the value is already <code>null</code>,
+ * return <code>true</code> immediately.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitUntilNull(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs(null, timeout);
- }
+ return this.waitUntilValueIs(null, timeout);
}
/**
* Suspend the current thread until the value changes
- * to something other than null or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return true if the specified
- * value was achieved; return false if a time-out occurred.
- * If the value is already NOT null, return true immediately.
+ * to something other than <code>null</code> or the specified time-out occurs.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the specified value was achieved; return <code>false</code>
+ * if a time-out occurred. If the value is already <em>not</em>
+ * <code>null</code>, return <code>true</code> immediately.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitUntilNotNull(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIsNot(null, timeout);
- }
+ return this.waitUntilValueIsNot(null, timeout);
}
/**
@@ -277,18 +353,20 @@ public class SynchronizedObject<T>
* something other than the specified value, then change
* it back to the specified value and continue executing.
* If the value does not change to something other than the
- * specified before the time-out, simply continue executing
+ * specified value before the time-out, simply continue executing
* without changing the value.
- * The time-out is specified in milliseconds. Return true if the value was
- * set to true; return false if a time-out occurred.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the value was set to the specified value; return <code>false</code>
+ * if a time-out occurred.
* If the value is already something other than the specified value, set
- * the value immediately and return true.
+ * the value immediately and return <code>true</code>.
+ * If the time-out is zero, wait indefinitely.
*/
- public boolean waitToSetValue(T v, long timeout) throws InterruptedException {
+ public boolean waitToSetValue(V v, long timeout) throws InterruptedException {
synchronized (this.mutex) {
- boolean success = this.waitUntilValueIsNot(v, timeout);
+ boolean success = this.waitUntilValueIsNot_(v, timeout);
if (success) {
- this.setValue(v);
+ this.setValue_(v);
}
return success;
}
@@ -296,19 +374,41 @@ public class SynchronizedObject<T>
/**
* Suspend the current thread until the value changes to something
- * other than null, then change it back to null and continue executing.
- * If the value does not change to something other than null before
- * the time-out, simply continue executing without changing the value.
- * The time-out is specified in milliseconds. Return true if the value was
- * set to false; return false if a time-out occurred.
- * If the value is already something other than null, set
- * the value to null immediately and return true.
+ * other than <code>null</code>, then change it back to <code>null</code>
+ * and continue executing. If the value does not change to something
+ * other than <code>null</code> before the time-out, simply continue
+ * executing without changing the value.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the value was set to <code>null</code>; return <code>false</code>
+ * if a time-out occurred.
+ * If the value is already something other than <code>null</code>, set
+ * the value to <code>null</code> immediately and return <code>true</code>.
+ * If the time-out is zero, wait indefinitely.
*/
public boolean waitToSetNull(long timeout) throws InterruptedException {
+ return this.waitToSetValue(null, timeout);
+ }
+
+ /**
+ * Suspend the current thread until the value changes to
+ * the specified expected value, then change it
+ * to the specified new value and continue executing.
+ * If the value does not change to the specified expected value
+ * before the time-out, simply continue executing without changing
+ * the value.
+ * The time-out is specified in milliseconds. Return <code>true</code>
+ * if the value was set to the specified new value; return
+ * <code>false</code> if a time-out occurred.
+ * If the value is already the specified expected value,
+ * set the value to the specified new value immediately.
+ * Return the previous value.
+ * If the time-out is zero, wait indefinitely.
+ */
+ public boolean waitToSwap(V expectedValue, V newValue, long timeout) throws InterruptedException {
synchronized (this.mutex) {
- boolean success = this.waitUntilNotNull(timeout);
+ boolean success = this.waitUntilValueIs_(expectedValue, timeout);
if (success) {
- this.setValue(null);
+ this.setValue_(newValue);
}
return success;
}
@@ -319,7 +419,7 @@ public class SynchronizedObject<T>
/**
* If current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the value in another
+ * with the mutex locked. This is useful for initializing the value from another
* thread.
*/
public void execute(Command command) throws InterruptedException {
@@ -335,11 +435,11 @@ public class SynchronizedObject<T>
// ********** standard methods **********
@Override
- public SynchronizedObject<T> clone() {
+ public SynchronizedObject<V> clone() {
try {
synchronized (this.mutex) {
@SuppressWarnings("unchecked")
- SynchronizedObject<T> clone = (SynchronizedObject<T>) super.clone();
+ SynchronizedObject<V> clone = (SynchronizedObject<V>) super.clone();
return clone;
}
} catch (CloneNotSupportedException ex) {
@@ -354,8 +454,7 @@ public class SynchronizedObject<T>
}
Object v1 = this.getValue();
Object v2 = ((SynchronizedObject<?>) obj).getValue();
- return (v1 == null) ?
- (v2 == null) : v1.equals(v2);
+ return (v1 == null) ? (v2 == null) : v1.equals(v2);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java
index 6271175b67..1b0b9f33d9 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SynchronizedStack.java
@@ -22,7 +22,7 @@ public class SynchronizedStack<E>
implements Stack<E>, Serializable
{
/** Backing stack. */
- private Stack<E> stack;
+ private final Stack<E> stack;
/** Object to synchronize on. */
private final Object mutex;
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java
index cdf48a6089..4e0c08a125 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java
@@ -54,7 +54,7 @@ import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
* It provides for state, property, collection, list, and tree change notifications to
* listeners.
* <p>
- * <b>NB1:</b> There is lots of copy-n-paste code in this class. Nearly all of this duplication
+ * <strong>NB1:</strong> There is lots of copy-n-paste code in this class. Nearly all of this duplication
* is an effort to prevent the unnecessary creation of new objects (typically event
* objects). Since many events are fired when there are no listeners, we postpone
* the creation of event objects until we know we have interested listeners.
@@ -65,16 +65,16 @@ import org.eclipse.jpt.utility.model.listener.TreeChangeListener;
* the case, as we have added support for "state" changes, "dirty" notification,
* and custom "notifiers", with more to come, I'm sure.... ~bjv
* <p>
- * <b>NB2:</b> This class will check to see if, during the firing of events, a listener
+ * <strong>NB2:</strong> This class will check to see if, during the firing of events, a listener
* on the original, cloned, list of listeners has been removed from the master
* list of listeners <em>before</em> it is notified. If the listener has been removed
* "concurrently" it will <em>not</em> be notified.
* <p>
- * <b>NB3:</b> Any listener that is added during the firing of events will <em>not</em> be
+ * <strong>NB3:</strong> Any listener that is added during the firing of events will <em>not</em> be
* also notified. This is a bit inconsistent with NB2, but seems reasonable
* since any added listener should already be in synch with the model.
* <p>
- * <b>NB4:</b> This class is serializable, but it will only write out listeners that
+ * <strong>NB4:</strong> This class is serializable, but it will only write out listeners that
* are also serializable while silently leaving behind listeners that are not.
*
* @see Model
@@ -281,13 +281,13 @@ public class ChangeSupport
return this.getListenerList(CHANGE_LISTENER_CLASS);
}
- private ChangeListener[] getChangeListeners() {
+ private Iterable<ChangeListener> getChangeListeners() {
ListenerList<ChangeListener> listenerList = this.getChangeListenerList();
return (listenerList == null) ? null : listenerList.getListeners();
}
private boolean hasChangeListener(ChangeListener listener) {
- return ArrayTools.contains(this.getChangeListeners(), listener);
+ return CollectionTools.contains(this.getChangeListeners(), listener);
}
@@ -320,20 +320,20 @@ public class ChangeSupport
return this.getListenerList(STATE_CHANGE_LISTENER_CLASS);
}
- private StateChangeListener[] getStateChangeListeners() {
+ private Iterable<StateChangeListener> getStateChangeListeners() {
ListenerList<StateChangeListener> listenerList = this.getStateChangeListenerList();
return (listenerList == null) ? null : listenerList.getListeners();
}
private boolean hasStateChangeListener(StateChangeListener listener) {
- return ArrayTools.contains(this.getStateChangeListeners(), listener);
+ return CollectionTools.contains(this.getStateChangeListeners(), listener);
}
/**
* Fire the specified state change event to any registered listeners.
*/
public void fireStateChanged(StateChangeEvent event) {
- StateChangeListener[] listeners = this.getStateChangeListeners();
+ Iterable<StateChangeListener> listeners = this.getStateChangeListeners();
if (listeners != null) {
for (StateChangeListener listener : listeners) {
if (this.hasStateChangeListener(listener)) { // verify listener is still listening
@@ -342,7 +342,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -359,7 +359,7 @@ public class ChangeSupport
public void fireStateChanged() {
// this.fireStateChanged(new StateChangeEvent(this.source));
StateChangeEvent event = null;
- StateChangeListener[] listeners = this.getStateChangeListeners();
+ Iterable<StateChangeListener> listeners = this.getStateChangeListeners();
if (listeners != null) {
for (StateChangeListener listener : listeners) {
if (this.hasStateChangeListener(listener)) { // verify listener is still listening
@@ -371,7 +371,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -416,13 +416,13 @@ public class ChangeSupport
return this.getListenerList(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
}
- private PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ private Iterable<PropertyChangeListener> getPropertyChangeListeners(String propertyName) {
ListenerList<PropertyChangeListener> listenerList = this.getPropertyChangeListenerList(propertyName);
return (listenerList == null) ? null : listenerList.getListeners();
}
private boolean hasPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- return ArrayTools.contains(this.getPropertyChangeListeners(propertyName), listener);
+ return CollectionTools.contains(this.getPropertyChangeListeners(propertyName), listener);
}
/**
@@ -442,7 +442,7 @@ public class ChangeSupport
*/
protected void firePropertyChanged_(PropertyChangeEvent event) {
String propertyName = event.getPropertyName();
- PropertyChangeListener[] listeners = this.getPropertyChangeListeners(propertyName);
+ Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
if (listeners != null) {
for (PropertyChangeListener listener : listeners) {
if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
@@ -451,7 +451,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -479,7 +479,7 @@ public class ChangeSupport
*/
protected void firePropertyChanged_(String propertyName, Object oldValue, Object newValue) {
PropertyChangeEvent event = null;
- PropertyChangeListener[] listeners = this.getPropertyChangeListeners(propertyName);
+ Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
if (listeners != null) {
for (PropertyChangeListener listener : listeners) {
if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
@@ -491,7 +491,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -523,7 +523,7 @@ public class ChangeSupport
*/
protected void firePropertyChanged_(String propertyName, int oldValue, int newValue) {
PropertyChangeEvent event = null;
- PropertyChangeListener[] listeners = this.getPropertyChangeListeners(propertyName);
+ Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
if (listeners != null) {
for (PropertyChangeListener listener : listeners) {
if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
@@ -535,7 +535,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -567,7 +567,7 @@ public class ChangeSupport
*/
protected void firePropertyChanged_(String propertyName, boolean oldValue, boolean newValue) {
PropertyChangeEvent event = null;
- PropertyChangeListener[] listeners = this.getPropertyChangeListeners(propertyName);
+ Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
if (listeners != null) {
for (PropertyChangeListener listener : listeners) {
if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
@@ -579,7 +579,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -624,13 +624,13 @@ public class ChangeSupport
return this.getListenerList(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
}
- private CollectionChangeListener[] getCollectionChangeListeners(String collectionName) {
+ private Iterable<CollectionChangeListener> getCollectionChangeListeners(String collectionName) {
ListenerList<CollectionChangeListener> listenerList = this.getCollectionChangeListenerList(collectionName);
return (listenerList == null) ? null : listenerList.getListeners();
}
private boolean hasCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- return ArrayTools.contains(this.getCollectionChangeListeners(collectionName), listener);
+ return CollectionTools.contains(this.getCollectionChangeListeners(collectionName), listener);
}
/**
@@ -647,7 +647,7 @@ public class ChangeSupport
*/
protected void fireItemsAdded_(CollectionAddEvent event) {
String collectionName = event.getCollectionName();
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -656,7 +656,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -681,7 +681,7 @@ public class ChangeSupport
*/
protected void fireItemsAdded_(String collectionName, Collection<?> addedItems) {
CollectionAddEvent event = null;
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -693,7 +693,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -713,7 +713,7 @@ public class ChangeSupport
// this.fireItemsAdded(collectionName, Collections.singleton(addedItem));
CollectionAddEvent event = null;
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -725,7 +725,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -752,7 +752,7 @@ public class ChangeSupport
*/
protected void fireItemsRemoved_(CollectionRemoveEvent event) {
String collectionName = event.getCollectionName();
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -761,7 +761,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -786,7 +786,7 @@ public class ChangeSupport
*/
protected void fireItemsRemoved_(String collectionName, Collection<?> removedItems) {
CollectionRemoveEvent event = null;
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -798,7 +798,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -818,7 +818,7 @@ public class ChangeSupport
// this.fireItemsRemoved(collectionName, Collections.singleton(removedItem));
CollectionRemoveEvent event = null;
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -830,7 +830,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -848,7 +848,7 @@ public class ChangeSupport
*/
public void fireCollectionCleared(CollectionClearEvent event) {
String collectionName = event.getCollectionName();
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -857,7 +857,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -874,7 +874,7 @@ public class ChangeSupport
// this.fireCollectionCleared(new CollectionClearEvent(this.source, collectionName));
CollectionClearEvent event = null;
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -886,7 +886,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -904,7 +904,7 @@ public class ChangeSupport
*/
public void fireCollectionChanged(CollectionChangeEvent event) {
String collectionName = event.getCollectionName();
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -913,7 +913,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -930,7 +930,7 @@ public class ChangeSupport
// this.fireCollectionChanged(new CollectionChangeEvent(this.source, collectionName, collection));
CollectionChangeEvent event = null;
- CollectionChangeListener[] listeners = this.getCollectionChangeListeners(collectionName);
+ Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
if (listeners != null) {
for (CollectionChangeListener listener : listeners) {
if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
@@ -942,7 +942,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1284,13 +1284,13 @@ public class ChangeSupport
return this.getListenerList(LIST_CHANGE_LISTENER_CLASS, listName);
}
- private ListChangeListener[] getListChangeListeners(String listName) {
+ private Iterable<ListChangeListener> getListChangeListeners(String listName) {
ListenerList<ListChangeListener> listenerList = this.getListChangeListenerList(listName);
return (listenerList == null) ? null : listenerList.getListeners();
}
private boolean hasListChangeListener(String listName, ListChangeListener listener) {
- return ArrayTools.contains(this.getListChangeListeners(listName), listener);
+ return CollectionTools.contains(this.getListChangeListeners(listName), listener);
}
/**
@@ -1307,7 +1307,7 @@ public class ChangeSupport
*/
protected void fireItemsAdded_(ListAddEvent event) {
String listName = event.getListName();
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1316,7 +1316,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1341,7 +1341,7 @@ public class ChangeSupport
*/
protected void fireItemsAdded_(String listName, int index, List<?> addedItems) {
ListAddEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1353,7 +1353,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1373,7 +1373,7 @@ public class ChangeSupport
// this.fireItemsAdded(listName, index, Collections.singletonList(addedItem));
ListAddEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1385,7 +1385,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1412,7 +1412,7 @@ public class ChangeSupport
*/
protected void fireItemsRemoved_(ListRemoveEvent event) {
String listName = event.getListName();
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1421,7 +1421,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1446,7 +1446,7 @@ public class ChangeSupport
*/
protected void fireItemsRemoved_(String listName, int index, List<?> removedItems) {
ListRemoveEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1458,7 +1458,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1478,7 +1478,7 @@ public class ChangeSupport
// this.fireItemsRemoved(listName, index, Collections.singletonList(removedItem));
ListRemoveEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1490,7 +1490,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1517,7 +1517,7 @@ public class ChangeSupport
*/
protected void fireItemsReplaced_(ListReplaceEvent event) {
String listName = event.getListName();
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1526,7 +1526,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1551,7 +1551,7 @@ public class ChangeSupport
*/
protected void fireItemsReplaced_(String listName, int index, List<?> newItems, List<?> oldItems) {
ListReplaceEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1563,7 +1563,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1591,7 +1591,7 @@ public class ChangeSupport
*/
protected void fireItemReplaced_(String listName, int index, Object newItem, Object oldItem) {
ListReplaceEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1603,7 +1603,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1631,7 +1631,7 @@ public class ChangeSupport
*/
protected void fireItemsMoved_(ListMoveEvent event) {
String listName = event.getListName();
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1640,7 +1640,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1666,7 +1666,7 @@ public class ChangeSupport
*/
protected void fireItemsMoved_(String listName, int targetIndex, int sourceIndex, int length) {
ListMoveEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1678,7 +1678,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1703,7 +1703,7 @@ public class ChangeSupport
*/
public void fireListCleared(ListClearEvent event) {
String listName = event.getListName();
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1712,7 +1712,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1729,7 +1729,7 @@ public class ChangeSupport
// this.fireListCleared(new ListClearEvent(this.source, listName));
ListClearEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1741,7 +1741,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1759,7 +1759,7 @@ public class ChangeSupport
*/
public void fireListChanged(ListChangeEvent event) {
String listName = event.getListName();
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1768,7 +1768,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -1785,7 +1785,7 @@ public class ChangeSupport
// this.fireListChanged(new ListChangeEvent(this.source, listName));
ListChangeEvent event = null;
- ListChangeListener[] listeners = this.getListChangeListeners(listName);
+ Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
if (listeners != null) {
for (ListChangeListener listener : listeners) {
if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
@@ -1797,7 +1797,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2366,13 +2366,13 @@ public class ChangeSupport
return this.getListenerList(TREE_CHANGE_LISTENER_CLASS, treeName);
}
- private TreeChangeListener[] getTreeChangeListeners(String treeName) {
+ private Iterable<TreeChangeListener> getTreeChangeListeners(String treeName) {
ListenerList<TreeChangeListener> listenerList = this.getTreeChangeListenerList(treeName);
return (listenerList == null) ? null : listenerList.getListeners();
}
private boolean hasTreeChangeListener(String treeName, TreeChangeListener listener) {
- return ArrayTools.contains(this.getTreeChangeListeners(treeName), listener);
+ return CollectionTools.contains(this.getTreeChangeListeners(treeName), listener);
}
/**
@@ -2380,7 +2380,7 @@ public class ChangeSupport
*/
public void fireNodeAdded(TreeAddEvent event) {
String treeName = event.getTreeName();
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2389,7 +2389,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2405,7 +2405,7 @@ public class ChangeSupport
public void fireNodeAdded(String treeName, List<?> path) {
// this.fireNodeAdded(new TreeAddEvent(this.source, treeName, path));
TreeAddEvent event = null;
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2417,7 +2417,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2435,7 +2435,7 @@ public class ChangeSupport
*/
public void fireNodeRemoved(TreeRemoveEvent event) {
String treeName = event.getTreeName();
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2444,7 +2444,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2461,7 +2461,7 @@ public class ChangeSupport
// this.fireNodeRemoved(new TreeRemoveEvent(this.source, treeName, path));
TreeRemoveEvent event = null;
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2473,7 +2473,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2491,7 +2491,7 @@ public class ChangeSupport
*/
public void fireTreeCleared(TreeClearEvent event) {
String treeName = event.getTreeName();
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2500,7 +2500,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2517,7 +2517,7 @@ public class ChangeSupport
// this.fireTreeCleared(new TreeClearEvent(this.source, treeName));
TreeClearEvent event = null;
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2529,7 +2529,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2547,7 +2547,7 @@ public class ChangeSupport
*/
public void fireTreeChanged(TreeChangeEvent event) {
String treeName = event.getTreeName();
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2556,7 +2556,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2573,7 +2573,7 @@ public class ChangeSupport
// this.fireTreeChanged(new TreeChangeEvent(this.source, treeName, nodes));
TreeChangeEvent event = null;
- TreeChangeListener[] listeners = this.getTreeChangeListeners(treeName);
+ Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
if (listeners != null) {
for (TreeChangeListener listener : listeners) {
if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
@@ -2585,7 +2585,7 @@ public class ChangeSupport
}
}
- ChangeListener[] changeListeners = this.getChangeListeners();
+ Iterable<ChangeListener> changeListeners = this.getChangeListeners();
if (changeListeners != null) {
for (ChangeListener changeListener : changeListeners) {
if (this.hasChangeListener(changeListener)) { // verify listener is still listening
@@ -2660,7 +2660,7 @@ public class ChangeSupport
}
boolean matches(Class<? extends EventListener> listenerClass, @SuppressWarnings("unused") String aspectName) {
- return this.listenerList.getListeners().getClass().getComponentType() == listenerClass;
+ return this.listenerList.getListenerType() == listenerClass;
}
boolean matches(Class<? extends EventListener> listenerClass) {
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 d30bf2ff60..2a0d236a83 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
@@ -29,7 +29,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* To maintain a reasonably consistent appearance to client code, we
* keep an internal list somewhat in synch with the wrapped collection.
* <p>
- * <b>NB:</b> Since we only listen to the wrapped collection when we have
+ * <strong>NB:</strong> Since we only listen to the wrapped collection when we have
* listeners ourselves and we can only stay in synch with the wrapped
* collection while we are listening to it, results to various methods
* (e.g. {@link #size()}, {@link #get(int)}) will be unpredictable whenever
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 2a7b7d330b..66881df0b3 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
@@ -37,7 +37,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* {@link CollectionValueModel}. This composite collection contains
* the combined items from all these component collections.
* <p>
- * <b>NB:</b> The wrapped collection must be an "identity set" that does not
+ * <strong>NB:</strong> The wrapped collection must be an "identity set" that does not
* contain the same item twice or this class will throw an exception.
* <p>
* Terminology:<ul>
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositePropertyValueModel.java
index 405eb6c471..a9cc888ddc 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositePropertyValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositePropertyValueModel.java
@@ -33,7 +33,7 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
* to return the current property value, as derived from the
* component values
* </ul>
- * <b>NB:</b> The wrapped collection must not contain any duplicates
+ * <strong>NB:</strong> The wrapped collection must not contain any duplicates
* or this class will throw an exception.
* <p>
*/
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
index 44712e4f75..27081444d0 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
@@ -31,7 +31,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* This wrapper extends a {@link ListValueModel} (or {@link CollectionValueModel})
* with fixed collections of items on either end.
* <p>
- * <b>NB:</b> Be careful using or wrapping this list value model, since the
+ * <strong>NB:</strong> Be careful using or wrapping this list value model, since the
* "extended" items may be unexpected by the client code or wrapper.
*/
public class ExtendedListValueModelWrapper<E>
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 5c6bbccb6e..0529dc5214 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
@@ -34,7 +34,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* adapter to be used with different filter criteria (e.g. when the user
* wants to view a list of <code>.java</code> files).
* <p>
- * <b>NB:</b> If the objects in the "filtered" collection can change in such a way
+ * <strong>NB:</strong> If the objects in the "filtered" collection can change in such a way
* that they should be removed from the "filtered" collection, you will
* need to wrap the original collection in an {@link ItemAspectListValueModelAdapter}.
* For example, if the filter only "accepts" items whose names begin
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 f27c64f79b..1450f14809 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
@@ -29,7 +29,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* <p>
* We keep an internal collection somewhat in synch with the wrapped list.
* <p>
- * <b>NB:</b> Since we only listen to the wrapped list when we have
+ * <strong>NB:</strong> Since we only listen to the wrapped list when we have
* listeners ourselves and we can only stay in synch with the wrapped
* list while we are listening to it, results to various methods
* (e.g. {@link #size()}, {@link iterator()}) will be unpredictable whenever
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
index 9e28edb74d..81296e735e 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
@@ -29,7 +29,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* adapter to be used with different sort criteria (e.g. when the user
* wants to sort a list of files first by name, then by date, then by size).
* <p>
- * <b>NB:</b> Since we only listen to the wrapped collection when we have
+ * <strong>NB:</strong> Since we only listen to the wrapped collection when we have
* listeners ourselves and we can only stay in synch with the wrapped
* collection while we are listening to it, results to various methods
* (e.g. {@link #size()}, {@link #get(int)}) will be
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelWrapper.java
index 17b2313f0d..ea39562a46 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelWrapper.java
@@ -35,7 +35,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* adapter to be used with different sort criteria (e.g. when the user
* wants to sort a list of files first by name, then by date, then by size).
* <p>
- * <b>NB:</b> Since we only listen to the wrapped collection when we have
+ * <strong>NB:</strong> Since we only listen to the wrapped collection when we have
* listeners ourselves and we can only stay in synch with the wrapped
* collection while we are listening to it, results to various methods
* (e.g. {@link #size()}, {@link #get(int)}) will be unpredictable whenever
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
index 0115904e88..cea3c6b9dd 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
@@ -36,7 +36,7 @@ import org.eclipse.jpt.utility.model.value.ListValueModel;
* The {@link Transformer} can be changed at any time; allowing the same
* adapter to be used with different transformations.
* <p>
- * <b>NB:</b> Since we only listen to the wrapped list when we have
+ * <strong>NB:</strong> Since we only listen to the wrapped list when we have
* listeners ourselves and we can only stay in synch with the wrapped
* list while we are listening to it, results to various methods
* (e.g. {@link #size()}, {@link #get(int)}) will be unpredictable whenever
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java
index f86ecdf91f..9effcdb82d 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ValueAspectAdapter.java
@@ -23,7 +23,7 @@ import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
* This is useful if you have a value that may change, but whose aspects can also
* change in a fashion that might be of interest to the client.
* <p>
- * <b>NB:</b> Clients will need to listen for two different change notifications:
+ * <strong>NB:</strong> Clients will need to listen for two different change notifications:
* a property change event will be be fired when the <em>value</em> changes;
* a state change event will be fired when an <em>aspect</em> of the value changes.
* <p>
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java
index fa54ec422f..956caa86c2 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JpaModelTests.java
@@ -79,11 +79,11 @@ public class JpaModelTests extends TestCase {
* pre-existing entities added.
*/
private TestFacetedProject buildTestProject() throws Exception {
- TestJavaProject testProject = TestJavaProject.buildJavaProject(ClassTools.shortClassNameForObject(this), true);
- testProject.installFacet("jst.utility", "1.0");
- testProject.createCompilationUnit("test.pkg", "TestEntity.java", "@Entity public class TestEntity {}");
- testProject.createCompilationUnit("test.pkg", "TestEntity2.java", "@Entity public class TestEntity2 {}");
- return testProject;
+ TestJavaProject tjp = TestJavaProject.buildJavaProject(ClassTools.shortClassNameForObject(this), true);
+ tjp.installFacet("jst.utility", "1.0");
+ tjp.createCompilationUnit("test.pkg", "TestEntity.java", "@Entity public class TestEntity {}");
+ tjp.createCompilationUnit("test.pkg", "TestEntity2.java", "@Entity public class TestEntity2 {}");
+ return tjp;
}
private IFile getFile(TestPlatformProject p, String path) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java
index d2f7d3ff05..33ea3129b4 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ListenerListTests.java
@@ -5,7 +5,7 @@ import java.util.EventListener;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ArrayTools;
+import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.ListenerList;
@SuppressWarnings("nls")
@@ -19,15 +19,15 @@ public class ListenerListTests extends TestCase {
ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
Listener listener1 = new LocalListener();
Listener listener2 = new LocalListener();
- Listener[] listeners = listenerList.getListeners();
- assertEquals(0, listeners.length);
+ Iterable<Listener> listeners = listenerList.getListeners();
+ assertEquals(0, CollectionTools.size(listeners));
listenerList.add(listener1);
listenerList.add(listener2);
listeners = listenerList.getListeners();
- assertEquals(2, listeners.length);
- assertTrue(ArrayTools.contains(listeners, listener1));
- assertTrue(ArrayTools.contains(listeners, listener2));
+ assertEquals(2, CollectionTools.size(listeners));
+ assertTrue(CollectionTools.contains(listeners, listener1));
+ assertTrue(CollectionTools.contains(listeners, listener2));
}
public void testSize() throws Exception {
@@ -85,15 +85,15 @@ public class ListenerListTests extends TestCase {
Listener listener2 = new LocalListener();
listenerList.add(listener1);
listenerList.add(listener2);
- assertTrue(ArrayTools.contains(listenerList.getListeners(), listener1));
- assertTrue(ArrayTools.contains(listenerList.getListeners(), listener2));
+ assertTrue(CollectionTools.contains(listenerList.getListeners(), listener1));
+ assertTrue(CollectionTools.contains(listenerList.getListeners(), listener2));
listenerList.remove(listener1);
- assertFalse(ArrayTools.contains(listenerList.getListeners(), listener1));
- assertTrue(ArrayTools.contains(listenerList.getListeners(), listener2));
+ assertFalse(CollectionTools.contains(listenerList.getListeners(), listener1));
+ assertTrue(CollectionTools.contains(listenerList.getListeners(), listener2));
listenerList.remove(listener2);
- assertFalse(ArrayTools.contains(listenerList.getListeners(), listener2));
+ assertFalse(CollectionTools.contains(listenerList.getListeners(), listener2));
}
public void testRemove_null() throws Exception {
@@ -130,12 +130,12 @@ public class ListenerListTests extends TestCase {
Listener listener2 = new LocalListener();
listenerList.add(listener1);
listenerList.add(listener2);
- assertTrue(ArrayTools.contains(listenerList.getListeners(), listener1));
- assertTrue(ArrayTools.contains(listenerList.getListeners(), listener2));
+ assertTrue(CollectionTools.contains(listenerList.getListeners(), listener1));
+ assertTrue(CollectionTools.contains(listenerList.getListeners(), listener2));
listenerList.clear();
- assertFalse(ArrayTools.contains(listenerList.getListeners(), listener1));
- assertFalse(ArrayTools.contains(listenerList.getListeners(), listener2));
+ assertFalse(CollectionTools.contains(listenerList.getListeners(), listener1));
+ assertFalse(CollectionTools.contains(listenerList.getListeners(), listener2));
}
//TODO - This test doesn't pass in the Eclipse build environment (Linux) for some reason
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java
index acf84ffef1..22276502f7 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java
@@ -13,7 +13,7 @@ import java.util.EventListener;
import junit.framework.TestCase;
-import org.eclipse.jpt.utility.internal.ArrayTools;
+import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.ListenerList;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.internal.model.ChangeSupport;
@@ -154,15 +154,15 @@ public class NewEventTests extends TestCase {
private ListenerList<FooChangeListener> getFooChangeListenerList() {
return this.getListenerList(FOO_CHANGE_LISTENER_CLASS);
}
- private FooChangeListener[] getFooChangeListeners() {
+ private Iterable<FooChangeListener> getFooChangeListeners() {
ListenerList<FooChangeListener> listenerList = this.getFooChangeListenerList();
return (listenerList == null) ? null : listenerList.getListeners();
}
private boolean hasFooChangeListener(FooChangeListener listener) {
- return ArrayTools.contains(this.getFooChangeListeners(), listener);
+ return CollectionTools.contains(this.getFooChangeListeners(), listener);
}
public void fireFooChanged() {
- FooChangeListener[] listeners = this.getFooChangeListeners();
+ Iterable<FooChangeListener> listeners = this.getFooChangeListeners();
if (listeners != null) {
FooChangeEvent event = null;
for (FooChangeListener listener : listeners) {

Back to the top