Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-04-23 11:06:31 +0000
committerEike Stepper2018-04-23 11:06:31 +0000
commit03800f7122fd19ca49170de208e97742a57047da (patch)
treea31ec908fbbb9ebb01c2faa9da67878b645ee9fb /plugins/org.eclipse.emf.cdo.common/src
parent5f582b20c8a4602fc0cc4f554e5098aa2cc7e8c9 (diff)
downloadcdo-03800f7122fd19ca49170de208e97742a57047da.tar.gz
cdo-03800f7122fd19ca49170de208e97742a57047da.tar.xz
cdo-03800f7122fd19ca49170de208e97742a57047da.zip
[405543] An unsettable many-valued reference that is set to an empty list is unset on new transaction
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405543
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java96
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java9
15 files changed, 212 insertions, 45 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
index 5ce24b2bd4..be19f375a0 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
@@ -33,7 +33,7 @@ public interface CDOID extends Comparable<CDOID>, Serializable
public static final CDOID NULL = org.eclipse.emf.cdo.internal.common.id.CDOIDNullImpl.INSTANCE;
/**
- * @since 4.6
+ * @since 4.7
*/
public static final CDOID NIL = org.eclipse.emf.cdo.internal.common.id.CDOIDNilImpl.INSTANCE;
@@ -42,7 +42,7 @@ public interface CDOID extends Comparable<CDOID>, Serializable
public boolean isNull();
/**
- * @since 4.6
+ * @since 4.7
*/
public boolean isNil();
@@ -77,7 +77,7 @@ public interface CDOID extends Comparable<CDOID>, Serializable
NULL('N'), //
/**
- * @since 4.6
+ * @since 4.7
*/
NIL('I'), //
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
index 204471bee0..c607b37ef7 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
@@ -454,7 +454,7 @@ public final class CDORevisionUtil
{
if (feature.isMany())
{
- CDOList list = revisionData.getList(feature);
+ CDOList list = revisionData.getListOrNull(feature);
if (list != null)
{
for (Object value : list)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
index a6d150c0f8..5ca36d23ee 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
@@ -405,12 +405,14 @@ public final class CDOClassInfoImpl implements InternalCDOClassInfo, Adapter.Int
{
out.println(eClass.getName());
+ out.println();
out.println("\t\t\tallPersistentFeatures");
for (EStructuralFeature feature : getAllPersistentFeatures())
{
out.println("\t" + eClass.getFeatureID(feature) + "\t" + feature.getName() + "\t" + (feature.isTransient() ? "transient" : "persistent"));
}
+ out.println();
out.println("\t\t\tsettingsFeatureIndices\tpersistentFeatureIndices\ttransientFeatureIndices");
for (int featureID = 0; featureID < settingsFeatureIndices.length; featureID++)
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
index 06e77c786d..f52e607554 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
@@ -208,4 +208,22 @@ public class CDOListImpl extends BasicEList<Object> implements InternalCDOList.C
flags &= ~USE_EQUALS_FLAG;
}
}
+
+ /**
+ * An IndexOutOfBoundsException that constructs a message from the argument data.
+ * <p>
+ * Having this avoids having the byte code that computes the message repeated/in-lined at the creation site.
+ *
+ * @author Eike Stepper
+ * @since 4.7
+ */
+ public static class IndexOutOfBoundsException extends BasicIndexOutOfBoundsException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public IndexOutOfBoundsException(int index, int size)
+ {
+ super(index, size);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java
index d1adfeaa53..325fb8d5c0 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java
@@ -52,7 +52,7 @@ public class CDOAddFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl imple
Object value = getValue();
InternalCDORevision internalRevision = (InternalCDORevision)revision;
- CDOList list = internalRevision.getList(feature);
+ CDOList list = internalRevision.getOrCreateList(feature);
if (index < 0)
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java
index dd9f949584..14d9a6274e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java
@@ -563,6 +563,18 @@ public class CDOListFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOL
{
listChanges.add(featureDelta);
}
+
+ if (featureDelta.getType() != CDOFeatureDelta.Type.UNSET)
+ {
+ EStructuralFeature feature = featureDelta.getFeature();
+ if (feature.isMany() && feature.isUnsettable())
+ {
+ if (listChanges.isEmpty())
+ {
+ listChanges.add(new CDOClearFeatureDeltaImpl(feature));
+ }
+ }
+ }
}
public Object applyTo(CDORevision revision)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
index 5a50399db4..bd8c0a65b5 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java
@@ -120,7 +120,7 @@ public class CDOMoveFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOM
EStructuralFeature feature = getFeature();
InternalCDORevision internalRevision = (InternalCDORevision)revision;
- CDOList list = internalRevision.getList(feature);
+ CDOList list = internalRevision.getListOrNull(feature);
if (oldPosition < 0)
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java
index 6af546a07a..b48cd7224a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java
@@ -71,7 +71,12 @@ public class CDORemoveFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl im
int index = getIndex();
InternalCDORevision internalRevision = (InternalCDORevision)revision;
- CDOList list = internalRevision.getList(feature);
+ CDOList list = internalRevision.getListOrNull(feature);
+ if (list == null)
+ {
+ return null;
+ }
+
return list.remove(index);
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
index 123c59bdbd..b47b69f69d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
@@ -455,7 +455,7 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
private void checkNoProxies(EList<?> list, CDORevision revision)
{
- if (!((InternalCDORevision)revision).isUnchunked())
+ if (list != null && !((InternalCDORevision)revision).isUnchunked())
{
for (Object element : list)
{
@@ -468,8 +468,17 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
}
};
- CDOList originList = originRevision.getList(feature);
- CDOList dirtyList = dirtyRevision.getList(feature);
+ CDOList originList = originRevision.getListOrNull(feature);
+ if (originList == null)
+ {
+ originList = new CDOListImpl(0, 0);
+ }
+
+ CDOList dirtyList = dirtyRevision.getListOrNull(feature);
+ if (dirtyList == null)
+ {
+ dirtyList = new CDOListImpl(0, 0);
+ }
analyzer.analyzeLists(originList, dirtyList, new NOOPList());
if (!changes.isEmpty())
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
index 050788c09e..455308b5f3 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
@@ -192,11 +192,14 @@ public abstract class AbstractCDORevision implements InternalCDORevision
{
if (feature.isMany())
{
- int index = 0;
- CDOList list = getList(feature);
- for (Object value : list)
+ CDOList list = getListOrNull(feature);
+ if (list != null)
{
- visitor.visit(feature, value, index++);
+ int index = 0;
+ for (Object value : list)
+ {
+ visitor.visit(feature, value, index++);
+ }
}
}
else
@@ -281,6 +284,18 @@ public abstract class AbstractCDORevision implements InternalCDORevision
return string;
}
+ @Deprecated
+ public CDOList getList(EStructuralFeature feature)
+ {
+ return getOrCreateList(feature);
+ }
+
+ @Deprecated
+ public CDOList getList(EStructuralFeature feature, int initialCapacity)
+ {
+ return getOrCreateList(feature, initialCapacity);
+ }
+
/**
* @since 4.2
*/
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
index 38caa46944..d422ff1989 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
@@ -39,6 +39,7 @@ import org.eclipse.emf.cdo.common.security.NoPermissionException;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.internal.common.bundle.OM;
import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.internal.common.revision.CDOListImpl;
import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
@@ -57,6 +58,7 @@ import org.eclipse.emf.ecore.util.FeatureMap.Entry;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.text.MessageFormat;
import java.util.Map;
@@ -99,6 +101,8 @@ public abstract class BaseCDORevision extends AbstractCDORevision
private static final byte PERMISSION_MASK = READ_PERMISSION_FLAG | WRITE_PERMISSION_FLAG; // 3
+ private static final Object[] EMPTY_ARRAY = {};
+
private CDOID id;
private CDOBranchPoint branchPoint;
@@ -663,7 +667,12 @@ public abstract class BaseCDORevision extends AbstractCDORevision
{
if (feature.isMany())
{
- CDOList list = getList(feature);
+ CDOList list = getListOrNull(feature);
+ if (list == null)
+ {
+ throw new CDOListImpl.IndexOutOfBoundsException(index, 0);
+ }
+
return list.get(index);
}
@@ -672,32 +681,32 @@ public abstract class BaseCDORevision extends AbstractCDORevision
public boolean contains(EStructuralFeature feature, Object value)
{
- CDOList list = getList(feature);
- return list.contains(value);
+ CDOList list = getListOrNull(feature);
+ return list != null && list.contains(value);
}
public int indexOf(EStructuralFeature feature, Object value)
{
- CDOList list = getList(feature);
- return list.indexOf(value);
+ CDOList list = getListOrNull(feature);
+ return list == null ? -1 : list.indexOf(value);
}
public int lastIndexOf(EStructuralFeature feature, Object value)
{
- CDOList list = getList(feature);
- return list.lastIndexOf(value);
+ CDOList list = getListOrNull(feature);
+ return list == null ? -1 : list.lastIndexOf(value);
}
public boolean isEmpty(EStructuralFeature feature)
{
- CDOList list = getList(feature);
- return list.isEmpty();
+ CDOList list = getListOrNull(feature);
+ return list == null || list.isEmpty();
}
public int size(EStructuralFeature feature)
{
- CDOList list = getList(feature);
- return list.size();
+ CDOList list = getListOrNull(feature);
+ return list == null ? 0 : list.size();
}
public Object[] toArray(EStructuralFeature feature)
@@ -707,8 +716,8 @@ public abstract class BaseCDORevision extends AbstractCDORevision
throw new IllegalStateException("!feature.isMany()");
}
- CDOList list = getList(feature);
- return list.toArray();
+ CDOList list = getListOrNull(feature);
+ return list == null ? EMPTY_ARRAY : list.toArray();
}
public <T> T[] toArray(EStructuralFeature feature, T[] array)
@@ -718,21 +727,33 @@ public abstract class BaseCDORevision extends AbstractCDORevision
throw new IllegalStateException("!feature.isMany()");
}
- CDOList list = getList(feature);
+ CDOList list = getListOrNull(feature);
+ if (list == null)
+ {
+ if (array.length != 0)
+ {
+ @SuppressWarnings("unchecked")
+ T[] emptyArray = (T[])Array.newInstance(array.getClass().getComponentType(), 0);
+ return emptyArray;
+ }
+
+ return array;
+ }
+
return list.toArray(array);
}
public void add(EStructuralFeature feature, int index, Object value)
{
- CDOList list = getList(feature);
+ CDOList list = getOrCreateList(feature);
list.add(index, value);
}
public void clear(EStructuralFeature feature)
{
- if (feature.isMany() && isListPreserving())
+ if (feature.isMany() && feature.isUnsettable())
{
- getList(feature).clear();
+ getOrCreateList(feature).clear();
}
else
{
@@ -742,13 +763,23 @@ public abstract class BaseCDORevision extends AbstractCDORevision
public Object move(EStructuralFeature feature, int targetIndex, int sourceIndex)
{
- CDOList list = getList(feature);
+ CDOList list = getListOrNull(feature);
+ if (list == null)
+ {
+ throw new CDOListImpl.IndexOutOfBoundsException(sourceIndex, 0);
+ }
+
return list.move(targetIndex, sourceIndex);
}
public Object remove(EStructuralFeature feature, int index)
{
- CDOList list = getList(feature);
+ CDOList list = getListOrNull(feature);
+ if (list == null)
+ {
+ throw new CDOListImpl.IndexOutOfBoundsException(index, 0);
+ }
+
return list.remove(index);
}
@@ -756,7 +787,7 @@ public abstract class BaseCDORevision extends AbstractCDORevision
{
if (feature.isMany())
{
- CDOList list = getList(feature);
+ CDOList list = getOrCreateList(feature);
return list.set(index, value);
}
@@ -767,7 +798,9 @@ public abstract class BaseCDORevision extends AbstractCDORevision
{
if (feature.isMany() && isListPreserving())
{
- getList(feature).clear();
+ // isListPreserving() is always false except for HibernateStoreAccessor.
+ // For performance reasons this Hibernate-specific feature should probably be implemented via a custom revision factory.
+ getOrCreateList(feature).clear();
}
else
{
@@ -872,19 +905,32 @@ public abstract class BaseCDORevision extends AbstractCDORevision
}
}
- public CDOList getList(EStructuralFeature feature)
+ /**
+ * @since 4.7
+ */
+ public CDOList getListOrNull(EStructuralFeature feature)
+ {
+ return getOrCreateList(feature, DO_NOT_CREATE_LIST);
+ }
+
+ public CDOList getOrCreateList(EStructuralFeature feature)
{
- return getList(feature, 0);
+ return getOrCreateList(feature, 0);
}
- public CDOList getList(EStructuralFeature feature, int size)
+ public CDOList getOrCreateList(EStructuralFeature feature, int size)
{
checkReadable(feature);
int featureIndex = getFeatureIndex(feature);
InternalCDOList list = (InternalCDOList)getValue(featureIndex);
- if (list == null && size != -1)
+ if (list == null)
{
+ if (size == DO_NOT_CREATE_LIST)
+ {
+ return null;
+ }
+
list = (InternalCDOList)CDOListFactory.DEFAULT.createList(size, 0, 0);
if (feature instanceof EReference && list instanceof ConfigurableEquality)
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
index 425ef7b162..dcc87974be 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
@@ -327,14 +327,31 @@ public abstract class DelegatingCDORevision implements InternalCDORevision
getDelegate().setList(feature, list);
}
+ @Deprecated
public CDOList getList(EStructuralFeature feature)
{
return getDelegate().getList(feature);
}
- public CDOList getList(EStructuralFeature feature, int size)
+ @Deprecated
+ public CDOList getList(EStructuralFeature feature, int initialCapacity)
{
- return getDelegate().getList(feature, size);
+ return getDelegate().getList(feature, initialCapacity);
+ }
+
+ public CDOList getListOrNull(EStructuralFeature feature)
+ {
+ return getDelegate().getListOrNull(feature);
+ }
+
+ public CDOList getOrCreateList(EStructuralFeature feature)
+ {
+ return getDelegate().getOrCreateList(feature);
+ }
+
+ public CDOList getOrCreateList(EStructuralFeature feature, int size)
+ {
+ return getDelegate().getOrCreateList(feature, size);
}
public void read(CDODataInput in) throws IOException
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java
index 1e69748144..fd61811bbe 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java
@@ -50,7 +50,7 @@ public interface InternalCDOList extends CDOList
public void setWithoutFrozenCheck(int i, Object value);
/**
- * A mixin interface for {@link InternalCDOList} that allows to optimize the speed of equality checks.
+ * A mix-in interface for {@link InternalCDOList} that allows to optimize the speed of equality checks.
*
* @author Eike Stepper
* @since 4.2
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
index ae190bc242..b2c586d81c 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
@@ -41,6 +41,11 @@ import java.util.List;
public interface InternalCDORevision extends CDORevision, CDORevisionData, CDOReferenceAdjustable, CDOBranchAdjustable
{
/**
+ * @since 4.7
+ */
+ public static final int DO_NOT_CREATE_LIST = -1;
+
+ /**
* @since 4.2
*/
public InternalCDOClassInfo getClassInfo();
@@ -103,14 +108,47 @@ public interface InternalCDORevision extends CDORevision, CDORevisionData, CDORe
public void setList(EStructuralFeature feature, InternalCDOList list);
+ /**
+ * @deprecated As of 4.7 use either {@link #getListOrNull(EStructuralFeature)} or {@link #getOrCreateList(EStructuralFeature)}.
+ */
+ @Deprecated
public CDOList getList(EStructuralFeature feature);
/**
+ * @deprecated As of 4.7 use either {@link #getListOrNull(EStructuralFeature)} or {@link #getOrCreateList(EStructuralFeature, int)}.
+ */
+ @Deprecated
+ public CDOList getList(EStructuralFeature feature, int initialCapacity);
+
+ /**
+ * @since 4.7
+ */
+ public CDOList getListOrNull(EStructuralFeature feature);
+
+ /**
+ * Same as {@link #getOrCreateList(EStructuralFeature, int) getOrCreateList(feature, 0)}.
+ * <p>
+ * <b>Warning</b>: Must be used with caution because list creation for an {@link EStructuralFeature#isUnsettable() unsettable}
+ * feature implies a transition from UNSET to SET!
+ *
+ * @since 4.7
+ */
+ public CDOList getOrCreateList(EStructuralFeature feature);
+
+ /**
+ * Returns the list that represents the passed feature, possibly creates it if needed.
+ * <p>
+ * <b>Warning</b>: Must be used with caution because list creation for an {@link EStructuralFeature#isUnsettable() unsettable}
+ * feature implies a transition from UNSET to SET!
+ *
* @param initialCapacity
* the initialCapacity of a new list to be created if this revision has no list so far (its size will always
* be 0), or -1 to skip list creation and return <code>null</code> in this case.
+ *
+ * @see #DO_NOT_CREATE_LIST
+ * @since 4.7
*/
- public CDOList getList(EStructuralFeature feature, int initialCapacity);
+ public CDOList getOrCreateList(EStructuralFeature feature, int initialCapacity);
/**
* @since 3.0
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java
index 90e5f56bf2..c8dd04e1d2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java
@@ -134,12 +134,17 @@ public class StubCDORevision extends AbstractCDORevision
throw new UnsupportedOperationException(getExceptionMessage());
}
- public CDOList getList(EStructuralFeature feature)
+ public CDOList getListOrNull(EStructuralFeature feature)
{
throw new UnsupportedOperationException(getExceptionMessage());
}
- public CDOList getList(EStructuralFeature feature, int size)
+ public CDOList getOrCreateList(EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException(getExceptionMessage());
+ }
+
+ public CDOList getOrCreateList(EStructuralFeature feature, int size)
{
throw new UnsupportedOperationException(getExceptionMessage());
}

Back to the top