001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id$
006: */package newprocess.impl;
007:
008: import java.util.Collection;
009: import java.util.Iterator;
010:
011: import newprocess.Condition;
012: import newprocess.ConditionProxy;
013: import newprocess.ConditionTerm;
014: import newprocess.NewprocessPackage;
015: import newprocess.validation.ConditionProxyValidator;
016: import newprocess.validation.ConditionProxyValidatorImpl;
017:
018: import org.eclipse.emf.common.notify.Notification;
019: import org.eclipse.emf.common.notify.NotificationChain;
020: import org.eclipse.emf.common.util.EList;
021: import org.eclipse.emf.ecore.EClass;
022: import org.eclipse.emf.ecore.InternalEObject;
023: import org.eclipse.emf.ecore.impl.ENotificationImpl;
024: import org.eclipse.emf.ecore.impl.EObjectImpl;
025: import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
026: import org.eclipse.emf.ecore.util.InternalEList;
027:
028: /**
029: * <!-- begin-user-doc -->
030: * An implementation of the model object '<em><b>Condition Proxy</b></em>'.
031: * <!-- end-user-doc -->
032: * <p>
033: * The following features are implemented:
034: * <ul>
035: * <li>{@link newprocess.impl.ConditionProxyImpl#getCondition <em>Condition</em>}</li>
036: * <li>{@link newprocess.impl.ConditionProxyImpl#isInverted <em>Inverted</em>}</li>
037: * <li>{@link newprocess.impl.ConditionProxyImpl#getProxyName <em>Proxy Name</em>}</li>
038: * <li>{@link newprocess.impl.ConditionProxyImpl#getConditionTerm <em>Condition Term</em>}</li>
039: * </ul>
040: * </p>
041: *
042: * @generated NOT
043: * @author sh
044: */
045: public class ConditionProxyImpl extends EObjectImpl implements
046: ConditionProxy, ConditionProxyValidator {
047:
048: /**
049: * The cached value of the '{@link #getCondition() <em>Condition</em>}' reference.
050: * <!-- begin-user-doc -->
051: * <!-- end-user-doc -->
052: * @see #getCondition()
053: * @generated
054: * @ordered
055: */
056: protected Condition condition = null;
057:
058: /**
059: * The default value of the '{@link #isInverted() <em>Inverted</em>}' attribute.
060: * <!-- begin-user-doc -->
061: * <!-- end-user-doc -->
062: * @see #isInverted()
063: * @generated
064: * @ordered
065: */
066: protected static final boolean INVERTED_EDEFAULT = false;
067:
068: /**
069: * The cached value of the '{@link #isInverted() <em>Inverted</em>}' attribute.
070: * <!-- begin-user-doc -->
071: * <!-- end-user-doc -->
072: * @see #isInverted()
073: * @generated
074: * @ordered
075: */
076: protected boolean inverted = INVERTED_EDEFAULT;
077:
078: /**
079: * The default value of the '{@link #getProxyName() <em>Proxy Name</em>}' attribute.
080: * <!-- begin-user-doc -->
081: * <!-- end-user-doc -->
082: * @see #getProxyName()
083: * @generated
084: * @ordered
085: */
086: protected static final String PROXY_NAME_EDEFAULT = null;
087:
088: /**
089: * The cached value of the '{@link #getProxyName() <em>Proxy Name</em>}' attribute.
090: * <!-- begin-user-doc -->
091: * <!-- end-user-doc -->
092: * @see #getProxyName()
093: * @generated
094: * @ordered
095: */
096: protected String proxyName = PROXY_NAME_EDEFAULT;
097:
098: /**
099: * The cached value of the '{@link #getConditionTerm() <em>Condition Term</em>}' reference list.
100: * <!-- begin-user-doc -->
101: * <!-- end-user-doc -->
102: * @see #getConditionTerm()
103: * @generated
104: * @ordered
105: */
106: protected EList<ConditionTerm> conditionTerm = null;
107:
108: /**
109: * <!-- begin-user-doc -->
110: * <!-- end-user-doc -->
111: * @generated
112: */
113: protected ConditionProxyImpl() {
114: super ();
115: }
116:
117: /**
118: * <!-- begin-user-doc -->
119: * <!-- end-user-doc -->
120: * @generated
121: */
122: @Override
123: protected EClass eStaticClass() {
124: return NewprocessPackage.Literals.CONDITION_PROXY;
125: }
126:
127: /**
128: * <!-- begin-user-doc -->
129: * <!-- end-user-doc -->
130: * @generated
131: */
132: public Condition getCondition() {
133: if (condition != null && condition.eIsProxy()) {
134: InternalEObject oldCondition = (InternalEObject) condition;
135: condition = (Condition) eResolveProxy(oldCondition);
136: if (condition != oldCondition) {
137: if (eNotificationRequired())
138: eNotify(new ENotificationImpl(
139: this ,
140: Notification.RESOLVE,
141: NewprocessPackage.CONDITION_PROXY__CONDITION,
142: oldCondition, condition));
143: }
144: }
145: return condition;
146: }
147:
148: /**
149: * <!-- begin-user-doc -->
150: * <!-- end-user-doc -->
151: * @generated
152: */
153: public Condition basicGetCondition() {
154: return condition;
155: }
156:
157: /**
158: * <!-- begin-user-doc -->
159: * <!-- end-user-doc -->
160: * @generated
161: */
162: public void setCondition(Condition newCondition) {
163: Condition oldCondition = condition;
164: condition = newCondition;
165: if (eNotificationRequired())
166: eNotify(new ENotificationImpl(this , Notification.SET,
167: NewprocessPackage.CONDITION_PROXY__CONDITION,
168: oldCondition, condition));
169: }
170:
171: /**
172: * <!-- begin-user-doc -->
173: * <!-- end-user-doc -->
174: * @generated
175: */
176: public boolean isInverted() {
177: return inverted;
178: }
179:
180: /**
181: * <!-- begin-user-doc -->
182: * <!-- end-user-doc -->
183: * @generated
184: */
185: public void setInverted(boolean newInverted) {
186: boolean oldInverted = inverted;
187: inverted = newInverted;
188: if (eNotificationRequired())
189: eNotify(new ENotificationImpl(this , Notification.SET,
190: NewprocessPackage.CONDITION_PROXY__INVERTED,
191: oldInverted, inverted));
192: }
193:
194: /**
195: * <!-- begin-user-doc -->
196: * <!-- end-user-doc -->
197: * @generated
198: */
199: public String getProxyName() {
200: return proxyName;
201: }
202:
203: /**
204: * <!-- begin-user-doc -->
205: * <!-- end-user-doc -->
206: * @generated
207: */
208: public void setProxyName(String newProxyName) {
209: String oldProxyName = proxyName;
210: proxyName = newProxyName;
211: if (eNotificationRequired())
212: eNotify(new ENotificationImpl(this , Notification.SET,
213: NewprocessPackage.CONDITION_PROXY__PROXY_NAME,
214: oldProxyName, proxyName));
215: }
216:
217: /**
218: * <!-- begin-user-doc -->
219: * <!-- end-user-doc -->
220: * @generated
221: */
222: public EList<ConditionTerm> getConditionTerm() {
223: if (conditionTerm == null) {
224: conditionTerm = new EObjectWithInverseResolvingEList<ConditionTerm>(
225: ConditionTerm.class, this ,
226: NewprocessPackage.CONDITION_PROXY__CONDITION_TERM,
227: NewprocessPackage.CONDITION_TERM__CONDITION_PROXY);
228: }
229: return conditionTerm;
230: }
231:
232: /**
233: * <!-- begin-user-doc -->
234: * do a name update an propagate it to all reference
235: * <!-- end-user-doc -->
236: * @generated NOT
237: * @author sh
238: */
239: public void performUpdate() {
240: updateName();
241: Iterator<ConditionTerm> it = getConditionTerm().iterator();
242: while (it.hasNext()) {
243: it.next().performUpdate();
244: }
245: }
246:
247: /**
248: * <!-- begin-user-doc -->
249: * <!-- end-user-doc -->
250: * @generated NOT
251: * @author sh
252: */
253: public void updateName() {
254: // update the name
255: if (getCondition() != null)
256: setProxyName(getCondition().getName());
257: else
258: setProxyName(null);
259:
260: if (getCondition() == null) {
261: // if the proxy is inverted and has a name
262: if (isInverted() && getProxyName() != null
263: && getProxyName() != ""
264: && getProxyName().startsWith("!") == false)
265: setProxyName("! ".concat(getProxyName()));
266:
267: // if the proxy isn't inverted and has a name
268: else if (!isInverted() && getProxyName() != null
269: && getProxyName() != ""
270: && getProxyName().startsWith("!")) {
271: String name = getProxyName().substring(2);
272: setProxyName(name);
273: }
274: } else {
275: String newName = getCondition().getName();
276: if (isInverted() && newName != null && newName != "") {
277: if (getProxyName() == null)
278: setProxyName("! ".concat(newName));
279: else if (getProxyName() != null
280: && getProxyName().startsWith("!") == false)
281: setProxyName("! ".concat(newName));
282: } else if (!isInverted() && newName != "")
283: if (getProxyName() != newName)
284: setProxyName(newName);
285: }
286: }
287:
288: /**
289: * <!-- begin-user-doc -->
290: * <!-- end-user-doc -->
291: * @generated
292: */
293: public void a() {
294: // TODO: implement this method
295: // Ensure that you remove @generated or mark it @generated NOT
296: throw new UnsupportedOperationException();
297: }
298:
299: /**
300: * <!-- begin-user-doc -->
301: * <!-- end-user-doc -->
302: * @generated
303: */
304: @SuppressWarnings("unchecked")
305: @Override
306: public NotificationChain eInverseAdd(InternalEObject otherEnd,
307: int featureID, NotificationChain msgs) {
308: switch (featureID) {
309: case NewprocessPackage.CONDITION_PROXY__CONDITION_TERM:
310: return ((InternalEList<InternalEObject>) (InternalEList<?>) getConditionTerm())
311: .basicAdd(otherEnd, msgs);
312: }
313: return super .eInverseAdd(otherEnd, featureID, msgs);
314: }
315:
316: /**
317: * <!-- begin-user-doc -->
318: * <!-- end-user-doc -->
319: * @generated
320: */
321: @Override
322: public NotificationChain eInverseRemove(InternalEObject otherEnd,
323: int featureID, NotificationChain msgs) {
324: switch (featureID) {
325: case NewprocessPackage.CONDITION_PROXY__CONDITION_TERM:
326: return ((InternalEList<?>) getConditionTerm()).basicRemove(
327: otherEnd, msgs);
328: }
329: return super .eInverseRemove(otherEnd, featureID, msgs);
330: }
331:
332: /**
333: * <!-- begin-user-doc -->
334: * <!-- end-user-doc -->
335: * @generated
336: */
337: @Override
338: public Object eGet(int featureID, boolean resolve, boolean coreType) {
339: switch (featureID) {
340: case NewprocessPackage.CONDITION_PROXY__CONDITION:
341: if (resolve)
342: return getCondition();
343: return basicGetCondition();
344: case NewprocessPackage.CONDITION_PROXY__INVERTED:
345: return isInverted() ? Boolean.TRUE : Boolean.FALSE;
346: case NewprocessPackage.CONDITION_PROXY__PROXY_NAME:
347: return getProxyName();
348: case NewprocessPackage.CONDITION_PROXY__CONDITION_TERM:
349: return getConditionTerm();
350: }
351: return super .eGet(featureID, resolve, coreType);
352: }
353:
354: /**
355: * <!-- begin-user-doc -->
356: * <!-- end-user-doc -->
357: * @generated
358: */
359: @SuppressWarnings("unchecked")
360: @Override
361: public void eSet(int featureID, Object newValue) {
362: switch (featureID) {
363: case NewprocessPackage.CONDITION_PROXY__CONDITION:
364: setCondition((Condition) newValue);
365: return;
366: case NewprocessPackage.CONDITION_PROXY__INVERTED:
367: setInverted(((Boolean) newValue).booleanValue());
368: return;
369: case NewprocessPackage.CONDITION_PROXY__PROXY_NAME:
370: setProxyName((String) newValue);
371: return;
372: case NewprocessPackage.CONDITION_PROXY__CONDITION_TERM:
373: getConditionTerm().clear();
374: getConditionTerm().addAll(
375: (Collection<? extends ConditionTerm>) newValue);
376: return;
377: }
378: super .eSet(featureID, newValue);
379: }
380:
381: /**
382: * <!-- begin-user-doc -->
383: * <!-- end-user-doc -->
384: * @generated
385: */
386: @Override
387: public void eUnset(int featureID) {
388: switch (featureID) {
389: case NewprocessPackage.CONDITION_PROXY__CONDITION:
390: setCondition((Condition) null);
391: return;
392: case NewprocessPackage.CONDITION_PROXY__INVERTED:
393: setInverted(INVERTED_EDEFAULT);
394: return;
395: case NewprocessPackage.CONDITION_PROXY__PROXY_NAME:
396: setProxyName(PROXY_NAME_EDEFAULT);
397: return;
398: case NewprocessPackage.CONDITION_PROXY__CONDITION_TERM:
399: getConditionTerm().clear();
400: return;
401: }
402: super .eUnset(featureID);
403: }
404:
405: /**
406: * <!-- begin-user-doc -->
407: * <!-- end-user-doc -->
408: * @generated
409: */
410: @Override
411: public boolean eIsSet(int featureID) {
412: switch (featureID) {
413: case NewprocessPackage.CONDITION_PROXY__CONDITION:
414: return condition != null;
415: case NewprocessPackage.CONDITION_PROXY__INVERTED:
416: return inverted != INVERTED_EDEFAULT;
417: case NewprocessPackage.CONDITION_PROXY__PROXY_NAME:
418: return PROXY_NAME_EDEFAULT == null ? proxyName != null
419: : !PROXY_NAME_EDEFAULT.equals(proxyName);
420: case NewprocessPackage.CONDITION_PROXY__CONDITION_TERM:
421: return conditionTerm != null && !conditionTerm.isEmpty();
422: }
423: return super .eIsSet(featureID);
424: }
425:
426: /**
427: * <!-- begin-user-doc -->
428: * <!-- end-user-doc -->
429: * @generated
430: */
431: @Override
432: public String toString() {
433: if (eIsProxy())
434: return super .toString();
435:
436: StringBuffer result = new StringBuffer(super .toString());
437: result.append(" (inverted: ");
438: result.append(inverted);
439: result.append(", proxyName: ");
440: result.append(proxyName);
441: result.append(')');
442: return result.toString();
443: }
444:
445: /**
446: * Validates the condition of the Proxy
447: * @author sh
448: */
449: public boolean validateCondition(ConditionProxy value) {
450: return ConditionProxyValidatorImpl.INSTANCE
451: .validateCondition(value);
452: }
453: } //ConditionProxyImpl
|