001 /**
002 * <copyright>
003 * </copyright>
004 *
005 * $Id$
006 */
007 package com.hammurapi.party.impl;
008
009 import com.hammurapi.party.Custom;
010 import com.hammurapi.party.Party;
011 import com.hammurapi.party.PartyPackage;
012 import com.hammurapi.party.Tag;
013
014 import java.util.Collection;
015 import java.util.Date;
016
017 import org.eclipse.emf.common.notify.Notification;
018 import org.eclipse.emf.common.notify.NotificationChain;
019
020 import org.eclipse.emf.common.util.EList;
021
022 import org.eclipse.emf.ecore.EClass;
023 import org.eclipse.emf.ecore.InternalEObject;
024
025 import org.eclipse.emf.ecore.impl.ENotificationImpl;
026 import org.eclipse.emf.ecore.impl.EObjectImpl;
027
028 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
029 import org.eclipse.emf.ecore.util.EcoreUtil;
030 import org.eclipse.emf.ecore.util.InternalEList;
031
032 /**
033 * <!-- begin-user-doc -->
034 * An implementation of the model object '<em><b>Custom</b></em>'.
035 * <!-- end-user-doc -->
036 * <p>
037 * The following features are implemented:
038 * <ul>
039 * <li>{@link com.hammurapi.party.impl.CustomImpl#getTags <em>Tags</em>}</li>
040 * <li>{@link com.hammurapi.party.impl.CustomImpl#getComment <em>Comment</em>}</li>
041 * <li>{@link com.hammurapi.party.impl.CustomImpl#getStart <em>Start</em>}</li>
042 * <li>{@link com.hammurapi.party.impl.CustomImpl#getEnd <em>End</em>}</li>
043 * <li>{@link com.hammurapi.party.impl.CustomImpl#getCategory <em>Category</em>}</li>
044 * <li>{@link com.hammurapi.party.impl.CustomImpl#getOwner <em>Owner</em>}</li>
045 * <li>{@link com.hammurapi.party.impl.CustomImpl#getLocation <em>Location</em>}</li>
046 * </ul>
047 * </p>
048 *
049 * @generated
050 */
051 public class CustomImpl extends EObjectImpl implements Custom {
052 /**
053 * The cached value of the '{@link #getTags() <em>Tags</em>}' containment reference list.
054 * <!-- begin-user-doc -->
055 * <!-- end-user-doc -->
056 * @see #getTags()
057 * @generated
058 * @ordered
059 */
060 protected EList<Tag> tags;
061
062 /**
063 * The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
064 * <!-- begin-user-doc -->
065 * <!-- end-user-doc -->
066 * @see #getComment()
067 * @generated
068 * @ordered
069 */
070 protected static final String COMMENT_EDEFAULT = null;
071
072 /**
073 * The cached value of the '{@link #getComment() <em>Comment</em>}' attribute.
074 * <!-- begin-user-doc -->
075 * <!-- end-user-doc -->
076 * @see #getComment()
077 * @generated
078 * @ordered
079 */
080 protected String comment = COMMENT_EDEFAULT;
081
082 /**
083 * The default value of the '{@link #getStart() <em>Start</em>}' attribute.
084 * <!-- begin-user-doc -->
085 * <!-- end-user-doc -->
086 * @see #getStart()
087 * @generated
088 * @ordered
089 */
090 protected static final Date START_EDEFAULT = null;
091
092 /**
093 * The cached value of the '{@link #getStart() <em>Start</em>}' attribute.
094 * <!-- begin-user-doc -->
095 * <!-- end-user-doc -->
096 * @see #getStart()
097 * @generated
098 * @ordered
099 */
100 protected Date start = START_EDEFAULT;
101
102 /**
103 * The default value of the '{@link #getEnd() <em>End</em>}' attribute.
104 * <!-- begin-user-doc -->
105 * <!-- end-user-doc -->
106 * @see #getEnd()
107 * @generated
108 * @ordered
109 */
110 protected static final Date END_EDEFAULT = null;
111
112 /**
113 * The cached value of the '{@link #getEnd() <em>End</em>}' attribute.
114 * <!-- begin-user-doc -->
115 * <!-- end-user-doc -->
116 * @see #getEnd()
117 * @generated
118 * @ordered
119 */
120 protected Date end = END_EDEFAULT;
121
122 /**
123 * The default value of the '{@link #getCategory() <em>Category</em>}' attribute.
124 * <!-- begin-user-doc -->
125 * <!-- end-user-doc -->
126 * @see #getCategory()
127 * @generated
128 * @ordered
129 */
130 protected static final String CATEGORY_EDEFAULT = null;
131
132 /**
133 * The cached value of the '{@link #getCategory() <em>Category</em>}' attribute.
134 * <!-- begin-user-doc -->
135 * <!-- end-user-doc -->
136 * @see #getCategory()
137 * @generated
138 * @ordered
139 */
140 protected String category = CATEGORY_EDEFAULT;
141
142 /**
143 * The default value of the '{@link #getLocation() <em>Location</em>}' attribute.
144 * <!-- begin-user-doc -->
145 * <!-- end-user-doc -->
146 * @see #getLocation()
147 * @generated
148 * @ordered
149 */
150 protected static final String LOCATION_EDEFAULT = null;
151
152 /**
153 * The cached value of the '{@link #getLocation() <em>Location</em>}' attribute.
154 * <!-- begin-user-doc -->
155 * <!-- end-user-doc -->
156 * @see #getLocation()
157 * @generated
158 * @ordered
159 */
160 protected String location = LOCATION_EDEFAULT;
161
162 /**
163 * <!-- begin-user-doc -->
164 * <!-- end-user-doc -->
165 * @generated
166 */
167 protected CustomImpl() {
168 super();
169 }
170
171 /**
172 * <!-- begin-user-doc -->
173 * <!-- end-user-doc -->
174 * @generated
175 */
176 @Override
177 protected EClass eStaticClass() {
178 return PartyPackage.Literals.CUSTOM;
179 }
180
181 /**
182 * <!-- begin-user-doc -->
183 * <!-- end-user-doc -->
184 * @generated
185 */
186 public EList<Tag> getTags() {
187 if (tags == null) {
188 tags = new EObjectContainmentEList<Tag>(Tag.class, this, PartyPackage.CUSTOM__TAGS);
189 }
190 return tags;
191 }
192
193 /**
194 * <!-- begin-user-doc -->
195 * <!-- end-user-doc -->
196 * @generated
197 */
198 public String getComment() {
199 return comment;
200 }
201
202 /**
203 * <!-- begin-user-doc -->
204 * <!-- end-user-doc -->
205 * @generated
206 */
207 public void setComment(String newComment) {
208 String oldComment = comment;
209 comment = newComment;
210 if (eNotificationRequired())
211 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.CUSTOM__COMMENT, oldComment, comment));
212 }
213
214 /**
215 * <!-- begin-user-doc -->
216 * <!-- end-user-doc -->
217 * @generated
218 */
219 public Date getStart() {
220 return start;
221 }
222
223 /**
224 * <!-- begin-user-doc -->
225 * <!-- end-user-doc -->
226 * @generated
227 */
228 public void setStart(Date newStart) {
229 Date oldStart = start;
230 start = newStart;
231 if (eNotificationRequired())
232 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.CUSTOM__START, oldStart, start));
233 }
234
235 /**
236 * <!-- begin-user-doc -->
237 * <!-- end-user-doc -->
238 * @generated
239 */
240 public Date getEnd() {
241 return end;
242 }
243
244 /**
245 * <!-- begin-user-doc -->
246 * <!-- end-user-doc -->
247 * @generated
248 */
249 public void setEnd(Date newEnd) {
250 Date oldEnd = end;
251 end = newEnd;
252 if (eNotificationRequired())
253 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.CUSTOM__END, oldEnd, end));
254 }
255
256 /**
257 * <!-- begin-user-doc -->
258 * <!-- end-user-doc -->
259 * @generated
260 */
261 public String getCategory() {
262 return category;
263 }
264
265 /**
266 * <!-- begin-user-doc -->
267 * <!-- end-user-doc -->
268 * @generated
269 */
270 public void setCategory(String newCategory) {
271 String oldCategory = category;
272 category = newCategory;
273 if (eNotificationRequired())
274 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.CUSTOM__CATEGORY, oldCategory, category));
275 }
276
277 /**
278 * <!-- begin-user-doc -->
279 * <!-- end-user-doc -->
280 * @generated
281 */
282 public Party getOwner() {
283 if (eContainerFeatureID() != PartyPackage.CUSTOM__OWNER) return null;
284 return (Party)eContainer();
285 }
286
287 /**
288 * <!-- begin-user-doc -->
289 * <!-- end-user-doc -->
290 * @generated
291 */
292 public NotificationChain basicSetOwner(Party newOwner, NotificationChain msgs) {
293 msgs = eBasicSetContainer((InternalEObject)newOwner, PartyPackage.CUSTOM__OWNER, msgs);
294 return msgs;
295 }
296
297 /**
298 * <!-- begin-user-doc -->
299 * <!-- end-user-doc -->
300 * @generated
301 */
302 public void setOwner(Party newOwner) {
303 if (newOwner != eInternalContainer() || (eContainerFeatureID() != PartyPackage.CUSTOM__OWNER && newOwner != null)) {
304 if (EcoreUtil.isAncestor(this, newOwner))
305 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
306 NotificationChain msgs = null;
307 if (eInternalContainer() != null)
308 msgs = eBasicRemoveFromContainer(msgs);
309 if (newOwner != null)
310 msgs = ((InternalEObject)newOwner).eInverseAdd(this, PartyPackage.PARTY__CONTACT_INFO, Party.class, msgs);
311 msgs = basicSetOwner(newOwner, msgs);
312 if (msgs != null) msgs.dispatch();
313 }
314 else if (eNotificationRequired())
315 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.CUSTOM__OWNER, newOwner, newOwner));
316 }
317
318 /**
319 * <!-- begin-user-doc -->
320 * <!-- end-user-doc -->
321 * @generated
322 */
323 public String getLocation() {
324 return location;
325 }
326
327 /**
328 * <!-- begin-user-doc -->
329 * <!-- end-user-doc -->
330 * @generated
331 */
332 public void setLocation(String newLocation) {
333 String oldLocation = location;
334 location = newLocation;
335 if (eNotificationRequired())
336 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.CUSTOM__LOCATION, oldLocation, location));
337 }
338
339 /**
340 * <!-- begin-user-doc -->
341 * <!-- end-user-doc -->
342 * @generated NOT
343 */
344 public boolean isEffectiveNow() {
345 return isEffective(new Date());
346 }
347
348 /**
349 * <!-- begin-user-doc -->
350 * <!-- end-user-doc -->
351 * @generated NOT
352 */
353 public boolean isEffective(Date date) {
354 if (getStart()!=null && getStart().after(date)) {
355 return false;
356 }
357
358 if (getEnd()!=null && getEnd().before(date)) {
359 return false;
360 }
361
362 return true;
363 }
364
365 /**
366 * <!-- begin-user-doc -->
367 * <!-- end-user-doc -->
368 * @generated
369 */
370 @Override
371 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
372 switch (featureID) {
373 case PartyPackage.CUSTOM__OWNER:
374 if (eInternalContainer() != null)
375 msgs = eBasicRemoveFromContainer(msgs);
376 return basicSetOwner((Party)otherEnd, msgs);
377 }
378 return super.eInverseAdd(otherEnd, featureID, msgs);
379 }
380
381 /**
382 * <!-- begin-user-doc -->
383 * <!-- end-user-doc -->
384 * @generated
385 */
386 @Override
387 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
388 switch (featureID) {
389 case PartyPackage.CUSTOM__TAGS:
390 return ((InternalEList<?>)getTags()).basicRemove(otherEnd, msgs);
391 case PartyPackage.CUSTOM__OWNER:
392 return basicSetOwner(null, msgs);
393 }
394 return super.eInverseRemove(otherEnd, featureID, msgs);
395 }
396
397 /**
398 * <!-- begin-user-doc -->
399 * <!-- end-user-doc -->
400 * @generated
401 */
402 @Override
403 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
404 switch (eContainerFeatureID()) {
405 case PartyPackage.CUSTOM__OWNER:
406 return eInternalContainer().eInverseRemove(this, PartyPackage.PARTY__CONTACT_INFO, Party.class, msgs);
407 }
408 return super.eBasicRemoveFromContainerFeature(msgs);
409 }
410
411 /**
412 * <!-- begin-user-doc -->
413 * <!-- end-user-doc -->
414 * @generated
415 */
416 @Override
417 public Object eGet(int featureID, boolean resolve, boolean coreType) {
418 switch (featureID) {
419 case PartyPackage.CUSTOM__TAGS:
420 return getTags();
421 case PartyPackage.CUSTOM__COMMENT:
422 return getComment();
423 case PartyPackage.CUSTOM__START:
424 return getStart();
425 case PartyPackage.CUSTOM__END:
426 return getEnd();
427 case PartyPackage.CUSTOM__CATEGORY:
428 return getCategory();
429 case PartyPackage.CUSTOM__OWNER:
430 return getOwner();
431 case PartyPackage.CUSTOM__LOCATION:
432 return getLocation();
433 }
434 return super.eGet(featureID, resolve, coreType);
435 }
436
437 /**
438 * <!-- begin-user-doc -->
439 * <!-- end-user-doc -->
440 * @generated
441 */
442 @SuppressWarnings("unchecked")
443 @Override
444 public void eSet(int featureID, Object newValue) {
445 switch (featureID) {
446 case PartyPackage.CUSTOM__TAGS:
447 getTags().clear();
448 getTags().addAll((Collection<? extends Tag>)newValue);
449 return;
450 case PartyPackage.CUSTOM__COMMENT:
451 setComment((String)newValue);
452 return;
453 case PartyPackage.CUSTOM__START:
454 setStart((Date)newValue);
455 return;
456 case PartyPackage.CUSTOM__END:
457 setEnd((Date)newValue);
458 return;
459 case PartyPackage.CUSTOM__CATEGORY:
460 setCategory((String)newValue);
461 return;
462 case PartyPackage.CUSTOM__OWNER:
463 setOwner((Party)newValue);
464 return;
465 case PartyPackage.CUSTOM__LOCATION:
466 setLocation((String)newValue);
467 return;
468 }
469 super.eSet(featureID, newValue);
470 }
471
472 /**
473 * <!-- begin-user-doc -->
474 * <!-- end-user-doc -->
475 * @generated
476 */
477 @Override
478 public void eUnset(int featureID) {
479 switch (featureID) {
480 case PartyPackage.CUSTOM__TAGS:
481 getTags().clear();
482 return;
483 case PartyPackage.CUSTOM__COMMENT:
484 setComment(COMMENT_EDEFAULT);
485 return;
486 case PartyPackage.CUSTOM__START:
487 setStart(START_EDEFAULT);
488 return;
489 case PartyPackage.CUSTOM__END:
490 setEnd(END_EDEFAULT);
491 return;
492 case PartyPackage.CUSTOM__CATEGORY:
493 setCategory(CATEGORY_EDEFAULT);
494 return;
495 case PartyPackage.CUSTOM__OWNER:
496 setOwner((Party)null);
497 return;
498 case PartyPackage.CUSTOM__LOCATION:
499 setLocation(LOCATION_EDEFAULT);
500 return;
501 }
502 super.eUnset(featureID);
503 }
504
505 /**
506 * <!-- begin-user-doc -->
507 * <!-- end-user-doc -->
508 * @generated
509 */
510 @Override
511 public boolean eIsSet(int featureID) {
512 switch (featureID) {
513 case PartyPackage.CUSTOM__TAGS:
514 return tags != null && !tags.isEmpty();
515 case PartyPackage.CUSTOM__COMMENT:
516 return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment);
517 case PartyPackage.CUSTOM__START:
518 return START_EDEFAULT == null ? start != null : !START_EDEFAULT.equals(start);
519 case PartyPackage.CUSTOM__END:
520 return END_EDEFAULT == null ? end != null : !END_EDEFAULT.equals(end);
521 case PartyPackage.CUSTOM__CATEGORY:
522 return CATEGORY_EDEFAULT == null ? category != null : !CATEGORY_EDEFAULT.equals(category);
523 case PartyPackage.CUSTOM__OWNER:
524 return getOwner() != null;
525 case PartyPackage.CUSTOM__LOCATION:
526 return LOCATION_EDEFAULT == null ? location != null : !LOCATION_EDEFAULT.equals(location);
527 }
528 return super.eIsSet(featureID);
529 }
530
531 /**
532 * <!-- begin-user-doc -->
533 * <!-- end-user-doc -->
534 * @generated
535 */
536 @Override
537 public String toString() {
538 if (eIsProxy()) return super.toString();
539
540 StringBuffer result = new StringBuffer(super.toString());
541 result.append(" (comment: ");
542 result.append(comment);
543 result.append(", start: ");
544 result.append(start);
545 result.append(", end: ");
546 result.append(end);
547 result.append(", category: ");
548 result.append(category);
549 result.append(", location: ");
550 result.append(location);
551 result.append(')');
552 return result.toString();
553 }
554
555 } //CustomImpl