Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4d0d64d85df439d117691c67de9e216bbbdd3d3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/**
 * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Simon McDuff - initial API and implementation
 *    Eike Stepper - maintenance
 */
package org.eclipse.emf.internal.cdo;

import org.eclipse.emf.cdo.CDODeltaNotification;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.spi.cdo.InternalCDOObject;

/**
 * @author Simon McDuff
 * @since 2.0
 */
public class CDODeltaNotificationImpl extends ENotificationImpl implements CDODeltaNotification
{
  private CDORevisionDelta revisionDelta;

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
      Object newValue, boolean isSetChange)
  {
    super(notifier, eventType, feature, oldValue, newValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
      Object newValue, int position, boolean wasSet)
  {
    super(notifier, eventType, feature, oldValue, newValue, position, wasSet);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
      Object newValue, int position)
  {
    super(notifier, eventType, feature, oldValue, newValue, position);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue,
      Object newValue)
  {
    super(notifier, eventType, feature, oldValue, newValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, boolean oldBooleanValue,
      boolean newBooleanValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldBooleanValue, newBooleanValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, boolean oldBooleanValue,
      boolean newBooleanValue)
  {
    super(notifier, eventType, featureID, oldBooleanValue, newBooleanValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, byte oldByteValue,
      byte newByteValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldByteValue, newByteValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, byte oldByteValue,
      byte newByteValue)
  {
    super(notifier, eventType, featureID, oldByteValue, newByteValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, char oldCharValue,
      char newCharValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldCharValue, newCharValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, char oldCharValue,
      char newCharValue)
  {
    super(notifier, eventType, featureID, oldCharValue, newCharValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, double oldDoubleValue,
      double newDoubleValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldDoubleValue, newDoubleValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, double oldDoubleValue,
      double newDoubleValue)
  {
    super(notifier, eventType, featureID, oldDoubleValue, newDoubleValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, float oldFloatValue,
      float newFloatValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldFloatValue, newFloatValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, float oldFloatValue,
      float newFloatValue)
  {
    super(notifier, eventType, featureID, oldFloatValue, newFloatValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, int oldIntValue,
      int newIntValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldIntValue, newIntValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, int oldIntValue,
      int newIntValue)
  {
    super(notifier, eventType, featureID, oldIntValue, newIntValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, long oldLongValue,
      long newLongValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldLongValue, newLongValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, long oldLongValue,
      long newLongValue)
  {
    super(notifier, eventType, featureID, oldLongValue, newLongValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
      Object newValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldValue, newValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
      Object newValue, int position, boolean wasSet)
  {
    super(notifier, eventType, featureID, oldValue, newValue, position, wasSet);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
      Object newValue, int position)
  {
    super(notifier, eventType, featureID, oldValue, newValue, position);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, Object oldValue,
      Object newValue)
  {
    super(notifier, eventType, featureID, oldValue, newValue);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, short oldShortValue,
      short newShortValue, boolean isSetChange)
  {
    super(notifier, eventType, featureID, oldShortValue, newShortValue, isSetChange);
  }

  public CDODeltaNotificationImpl(InternalEObject notifier, int eventType, int featureID, short oldShortValue,
      short newShortValue)
  {
    super(notifier, eventType, featureID, oldShortValue, newShortValue);
  }

  private InternalCDOObject getCDOObject()
  {
    return (InternalCDOObject)getNotifier();
  }

  @Override
  public Object getNewValue()
  {
    Object object = super.getNewValue();
    return adapt(object);
  }

  @Override
  public Object getOldValue()
  {
    Object oldValue = super.getOldValue();
    if (oldValue == null && getEventType() == Notification.REMOVE_MANY)
    {
      Object feature = getFeature();
      if (feature instanceof EStructuralFeature)
      {
        EStructuralFeature structuralFeature = (EStructuralFeature)feature;
        if (structuralFeature.isMany())
        {
          return ECollections.emptyEList();
        }
      }
    }

    return adapt(oldValue);
  }

  public Object adapt(Object object)
  {
    if (object instanceof CDOID)
    {
      object = getCDOObject().cdoView().getObject((CDOID)object, true);
    }

    return object;
  }

  public boolean hasNext()
  {
    return next != null;
  }

  public CDORevisionDelta getRevisionDelta()
  {
    return revisionDelta;
  }

  public void setRevisionDelta(CDORevisionDelta revisionDelta)
  {
    this.revisionDelta = revisionDelta;
  }

  @Override
  public boolean merge(Notification notification)
  {
    if (eventType == REMOVE_MANY && newValue == null)
    {
      // Means that clear all was executed and no merging can appear
      return false;
    }

    return super.merge(notification);
  }
}

Back to the top