001 /**
002 * <copyright>
003 * </copyright>
004 *
005 * $Id$
006 */
007 package com.hammurapi.party.impl;
008
009 import com.hammurapi.party.Party;
010 import com.hammurapi.party.PartyPackage;
011 import com.hammurapi.party.Phone;
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>Phone</b></em>'.
035 * <!-- end-user-doc -->
036 * <p>
037 * The following features are implemented:
038 * <ul>
039 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getTags <em>Tags</em>}</li>
040 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getComment <em>Comment</em>}</li>
041 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getStart <em>Start</em>}</li>
042 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getEnd <em>End</em>}</li>
043 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getCategory <em>Category</em>}</li>
044 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getOwner <em>Owner</em>}</li>
045 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getCountryCode <em>Country Code</em>}</li>
046 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getAreaCode <em>Area Code</em>}</li>
047 * <li>{@link com.hammurapi.party.impl.PhoneImpl#getNumber <em>Number</em>}</li>
048 * </ul>
049 * </p>
050 *
051 * @generated
052 */
053 public class PhoneImpl extends EObjectImpl implements Phone {
054 /**
055 * The cached value of the '{@link #getTags() <em>Tags</em>}' containment reference list.
056 * <!-- begin-user-doc -->
057 * <!-- end-user-doc -->
058 * @see #getTags()
059 * @generated
060 * @ordered
061 */
062 protected EList<Tag> tags;
063
064 /**
065 * The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
066 * <!-- begin-user-doc -->
067 * <!-- end-user-doc -->
068 * @see #getComment()
069 * @generated
070 * @ordered
071 */
072 protected static final String COMMENT_EDEFAULT = null;
073
074 /**
075 * The cached value of the '{@link #getComment() <em>Comment</em>}' attribute.
076 * <!-- begin-user-doc -->
077 * <!-- end-user-doc -->
078 * @see #getComment()
079 * @generated
080 * @ordered
081 */
082 protected String comment = COMMENT_EDEFAULT;
083
084 /**
085 * The default value of the '{@link #getStart() <em>Start</em>}' attribute.
086 * <!-- begin-user-doc -->
087 * <!-- end-user-doc -->
088 * @see #getStart()
089 * @generated
090 * @ordered
091 */
092 protected static final Date START_EDEFAULT = null;
093
094 /**
095 * The cached value of the '{@link #getStart() <em>Start</em>}' attribute.
096 * <!-- begin-user-doc -->
097 * <!-- end-user-doc -->
098 * @see #getStart()
099 * @generated
100 * @ordered
101 */
102 protected Date start = START_EDEFAULT;
103
104 /**
105 * The default value of the '{@link #getEnd() <em>End</em>}' attribute.
106 * <!-- begin-user-doc -->
107 * <!-- end-user-doc -->
108 * @see #getEnd()
109 * @generated
110 * @ordered
111 */
112 protected static final Date END_EDEFAULT = null;
113
114 /**
115 * The cached value of the '{@link #getEnd() <em>End</em>}' attribute.
116 * <!-- begin-user-doc -->
117 * <!-- end-user-doc -->
118 * @see #getEnd()
119 * @generated
120 * @ordered
121 */
122 protected Date end = END_EDEFAULT;
123
124 /**
125 * The default value of the '{@link #getCategory() <em>Category</em>}' attribute.
126 * <!-- begin-user-doc -->
127 * <!-- end-user-doc -->
128 * @see #getCategory()
129 * @generated
130 * @ordered
131 */
132 protected static final String CATEGORY_EDEFAULT = null;
133
134 /**
135 * The cached value of the '{@link #getCategory() <em>Category</em>}' attribute.
136 * <!-- begin-user-doc -->
137 * <!-- end-user-doc -->
138 * @see #getCategory()
139 * @generated
140 * @ordered
141 */
142 protected String category = CATEGORY_EDEFAULT;
143
144 /**
145 * The default value of the '{@link #getCountryCode() <em>Country Code</em>}' attribute.
146 * <!-- begin-user-doc -->
147 * <!-- end-user-doc -->
148 * @see #getCountryCode()
149 * @generated
150 * @ordered
151 */
152 protected static final String COUNTRY_CODE_EDEFAULT = null;
153
154 /**
155 * The cached value of the '{@link #getCountryCode() <em>Country Code</em>}' attribute.
156 * <!-- begin-user-doc -->
157 * <!-- end-user-doc -->
158 * @see #getCountryCode()
159 * @generated
160 * @ordered
161 */
162 protected String countryCode = COUNTRY_CODE_EDEFAULT;
163
164 /**
165 * The default value of the '{@link #getAreaCode() <em>Area Code</em>}' attribute.
166 * <!-- begin-user-doc -->
167 * <!-- end-user-doc -->
168 * @see #getAreaCode()
169 * @generated
170 * @ordered
171 */
172 protected static final int AREA_CODE_EDEFAULT = 0;
173
174 /**
175 * The cached value of the '{@link #getAreaCode() <em>Area Code</em>}' attribute.
176 * <!-- begin-user-doc -->
177 * <!-- end-user-doc -->
178 * @see #getAreaCode()
179 * @generated
180 * @ordered
181 */
182 protected int areaCode = AREA_CODE_EDEFAULT;
183
184 /**
185 * The default value of the '{@link #getNumber() <em>Number</em>}' attribute.
186 * <!-- begin-user-doc -->
187 * <!-- end-user-doc -->
188 * @see #getNumber()
189 * @generated
190 * @ordered
191 */
192 protected static final String NUMBER_EDEFAULT = null;
193
194 /**
195 * The cached value of the '{@link #getNumber() <em>Number</em>}' attribute.
196 * <!-- begin-user-doc -->
197 * <!-- end-user-doc -->
198 * @see #getNumber()
199 * @generated
200 * @ordered
201 */
202 protected String number = NUMBER_EDEFAULT;
203
204 /**
205 * <!-- begin-user-doc -->
206 * <!-- end-user-doc -->
207 * @generated
208 */
209 protected PhoneImpl() {
210 super();
211 }
212
213 /**
214 * <!-- begin-user-doc -->
215 * <!-- end-user-doc -->
216 * @generated
217 */
218 @Override
219 protected EClass eStaticClass() {
220 return PartyPackage.Literals.PHONE;
221 }
222
223 /**
224 * <!-- begin-user-doc -->
225 * <!-- end-user-doc -->
226 * @generated
227 */
228 public EList<Tag> getTags() {
229 if (tags == null) {
230 tags = new EObjectContainmentEList<Tag>(Tag.class, this, PartyPackage.PHONE__TAGS);
231 }
232 return tags;
233 }
234
235 /**
236 * <!-- begin-user-doc -->
237 * <!-- end-user-doc -->
238 * @generated
239 */
240 public String getComment() {
241 return comment;
242 }
243
244 /**
245 * <!-- begin-user-doc -->
246 * <!-- end-user-doc -->
247 * @generated
248 */
249 public void setComment(String newComment) {
250 String oldComment = comment;
251 comment = newComment;
252 if (eNotificationRequired())
253 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__COMMENT, oldComment, comment));
254 }
255
256 /**
257 * <!-- begin-user-doc -->
258 * <!-- end-user-doc -->
259 * @generated
260 */
261 public Date getStart() {
262 return start;
263 }
264
265 /**
266 * <!-- begin-user-doc -->
267 * <!-- end-user-doc -->
268 * @generated
269 */
270 public void setStart(Date newStart) {
271 Date oldStart = start;
272 start = newStart;
273 if (eNotificationRequired())
274 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__START, oldStart, start));
275 }
276
277 /**
278 * <!-- begin-user-doc -->
279 * <!-- end-user-doc -->
280 * @generated
281 */
282 public Date getEnd() {
283 return end;
284 }
285
286 /**
287 * <!-- begin-user-doc -->
288 * <!-- end-user-doc -->
289 * @generated
290 */
291 public void setEnd(Date newEnd) {
292 Date oldEnd = end;
293 end = newEnd;
294 if (eNotificationRequired())
295 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__END, oldEnd, end));
296 }
297
298 /**
299 * <!-- begin-user-doc -->
300 * <!-- end-user-doc -->
301 * @generated
302 */
303 public String getCategory() {
304 return category;
305 }
306
307 /**
308 * <!-- begin-user-doc -->
309 * <!-- end-user-doc -->
310 * @generated
311 */
312 public void setCategory(String newCategory) {
313 String oldCategory = category;
314 category = newCategory;
315 if (eNotificationRequired())
316 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__CATEGORY, oldCategory, category));
317 }
318
319 /**
320 * <!-- begin-user-doc -->
321 * <!-- end-user-doc -->
322 * @generated
323 */
324 public Party getOwner() {
325 if (eContainerFeatureID() != PartyPackage.PHONE__OWNER) return null;
326 return (Party)eContainer();
327 }
328
329 /**
330 * <!-- begin-user-doc -->
331 * <!-- end-user-doc -->
332 * @generated
333 */
334 public NotificationChain basicSetOwner(Party newOwner, NotificationChain msgs) {
335 msgs = eBasicSetContainer((InternalEObject)newOwner, PartyPackage.PHONE__OWNER, msgs);
336 return msgs;
337 }
338
339 /**
340 * <!-- begin-user-doc -->
341 * <!-- end-user-doc -->
342 * @generated
343 */
344 public void setOwner(Party newOwner) {
345 if (newOwner != eInternalContainer() || (eContainerFeatureID() != PartyPackage.PHONE__OWNER && newOwner != null)) {
346 if (EcoreUtil.isAncestor(this, newOwner))
347 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
348 NotificationChain msgs = null;
349 if (eInternalContainer() != null)
350 msgs = eBasicRemoveFromContainer(msgs);
351 if (newOwner != null)
352 msgs = ((InternalEObject)newOwner).eInverseAdd(this, PartyPackage.PARTY__CONTACT_INFO, Party.class, msgs);
353 msgs = basicSetOwner(newOwner, msgs);
354 if (msgs != null) msgs.dispatch();
355 }
356 else if (eNotificationRequired())
357 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__OWNER, newOwner, newOwner));
358 }
359
360 /**
361 * <!-- begin-user-doc -->
362 * <!-- end-user-doc -->
363 * @generated
364 */
365 public String getCountryCode() {
366 return countryCode;
367 }
368
369 /**
370 * <!-- begin-user-doc -->
371 * <!-- end-user-doc -->
372 * @generated
373 */
374 public void setCountryCode(String newCountryCode) {
375 String oldCountryCode = countryCode;
376 countryCode = newCountryCode;
377 if (eNotificationRequired())
378 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__COUNTRY_CODE, oldCountryCode, countryCode));
379 }
380
381 /**
382 * <!-- begin-user-doc -->
383 * <!-- end-user-doc -->
384 * @generated
385 */
386 public int getAreaCode() {
387 return areaCode;
388 }
389
390 /**
391 * <!-- begin-user-doc -->
392 * <!-- end-user-doc -->
393 * @generated
394 */
395 public void setAreaCode(int newAreaCode) {
396 int oldAreaCode = areaCode;
397 areaCode = newAreaCode;
398 if (eNotificationRequired())
399 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__AREA_CODE, oldAreaCode, areaCode));
400 }
401
402 /**
403 * <!-- begin-user-doc -->
404 * <!-- end-user-doc -->
405 * @generated
406 */
407 public String getNumber() {
408 return number;
409 }
410
411 /**
412 * <!-- begin-user-doc -->
413 * <!-- end-user-doc -->
414 * @generated
415 */
416 public void setNumber(String newNumber) {
417 String oldNumber = number;
418 number = newNumber;
419 if (eNotificationRequired())
420 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PHONE__NUMBER, oldNumber, number));
421 }
422
423
424 /**
425 * <!-- begin-user-doc -->
426 * <!-- end-user-doc -->
427 * @generated NOT
428 */
429 public boolean isEffectiveNow() {
430 return isEffective(new Date());
431 }
432
433 /**
434 * <!-- begin-user-doc -->
435 * <!-- end-user-doc -->
436 * @generated NOT
437 */
438 public boolean isEffective(Date date) {
439 if (getStart()!=null && getStart().after(date)) {
440 return false;
441 }
442
443 if (getEnd()!=null && getEnd().before(date)) {
444 return false;
445 }
446
447 return true;
448 }
449
450 /**
451 * <!-- begin-user-doc -->
452 * <!-- end-user-doc -->
453 * @generated
454 */
455 @Override
456 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
457 switch (featureID) {
458 case PartyPackage.PHONE__OWNER:
459 if (eInternalContainer() != null)
460 msgs = eBasicRemoveFromContainer(msgs);
461 return basicSetOwner((Party)otherEnd, msgs);
462 }
463 return super.eInverseAdd(otherEnd, featureID, msgs);
464 }
465
466 /**
467 * <!-- begin-user-doc -->
468 * <!-- end-user-doc -->
469 * @generated
470 */
471 @Override
472 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
473 switch (featureID) {
474 case PartyPackage.PHONE__TAGS:
475 return ((InternalEList<?>)getTags()).basicRemove(otherEnd, msgs);
476 case PartyPackage.PHONE__OWNER:
477 return basicSetOwner(null, msgs);
478 }
479 return super.eInverseRemove(otherEnd, featureID, msgs);
480 }
481
482 /**
483 * <!-- begin-user-doc -->
484 * <!-- end-user-doc -->
485 * @generated
486 */
487 @Override
488 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
489 switch (eContainerFeatureID()) {
490 case PartyPackage.PHONE__OWNER:
491 return eInternalContainer().eInverseRemove(this, PartyPackage.PARTY__CONTACT_INFO, Party.class, msgs);
492 }
493 return super.eBasicRemoveFromContainerFeature(msgs);
494 }
495
496 /**
497 * <!-- begin-user-doc -->
498 * <!-- end-user-doc -->
499 * @generated
500 */
501 @Override
502 public Object eGet(int featureID, boolean resolve, boolean coreType) {
503 switch (featureID) {
504 case PartyPackage.PHONE__TAGS:
505 return getTags();
506 case PartyPackage.PHONE__COMMENT:
507 return getComment();
508 case PartyPackage.PHONE__START:
509 return getStart();
510 case PartyPackage.PHONE__END:
511 return getEnd();
512 case PartyPackage.PHONE__CATEGORY:
513 return getCategory();
514 case PartyPackage.PHONE__OWNER:
515 return getOwner();
516 case PartyPackage.PHONE__COUNTRY_CODE:
517 return getCountryCode();
518 case PartyPackage.PHONE__AREA_CODE:
519 return getAreaCode();
520 case PartyPackage.PHONE__NUMBER:
521 return getNumber();
522 }
523 return super.eGet(featureID, resolve, coreType);
524 }
525
526 /**
527 * <!-- begin-user-doc -->
528 * <!-- end-user-doc -->
529 * @generated
530 */
531 @SuppressWarnings("unchecked")
532 @Override
533 public void eSet(int featureID, Object newValue) {
534 switch (featureID) {
535 case PartyPackage.PHONE__TAGS:
536 getTags().clear();
537 getTags().addAll((Collection<? extends Tag>)newValue);
538 return;
539 case PartyPackage.PHONE__COMMENT:
540 setComment((String)newValue);
541 return;
542 case PartyPackage.PHONE__START:
543 setStart((Date)newValue);
544 return;
545 case PartyPackage.PHONE__END:
546 setEnd((Date)newValue);
547 return;
548 case PartyPackage.PHONE__CATEGORY:
549 setCategory((String)newValue);
550 return;
551 case PartyPackage.PHONE__OWNER:
552 setOwner((Party)newValue);
553 return;
554 case PartyPackage.PHONE__COUNTRY_CODE:
555 setCountryCode((String)newValue);
556 return;
557 case PartyPackage.PHONE__AREA_CODE:
558 setAreaCode((Integer)newValue);
559 return;
560 case PartyPackage.PHONE__NUMBER:
561 setNumber((String)newValue);
562 return;
563 }
564 super.eSet(featureID, newValue);
565 }
566
567 /**
568 * <!-- begin-user-doc -->
569 * <!-- end-user-doc -->
570 * @generated
571 */
572 @Override
573 public void eUnset(int featureID) {
574 switch (featureID) {
575 case PartyPackage.PHONE__TAGS:
576 getTags().clear();
577 return;
578 case PartyPackage.PHONE__COMMENT:
579 setComment(COMMENT_EDEFAULT);
580 return;
581 case PartyPackage.PHONE__START:
582 setStart(START_EDEFAULT);
583 return;
584 case PartyPackage.PHONE__END:
585 setEnd(END_EDEFAULT);
586 return;
587 case PartyPackage.PHONE__CATEGORY:
588 setCategory(CATEGORY_EDEFAULT);
589 return;
590 case PartyPackage.PHONE__OWNER:
591 setOwner((Party)null);
592 return;
593 case PartyPackage.PHONE__COUNTRY_CODE:
594 setCountryCode(COUNTRY_CODE_EDEFAULT);
595 return;
596 case PartyPackage.PHONE__AREA_CODE:
597 setAreaCode(AREA_CODE_EDEFAULT);
598 return;
599 case PartyPackage.PHONE__NUMBER:
600 setNumber(NUMBER_EDEFAULT);
601 return;
602 }
603 super.eUnset(featureID);
604 }
605
606 /**
607 * <!-- begin-user-doc -->
608 * <!-- end-user-doc -->
609 * @generated
610 */
611 @Override
612 public boolean eIsSet(int featureID) {
613 switch (featureID) {
614 case PartyPackage.PHONE__TAGS:
615 return tags != null && !tags.isEmpty();
616 case PartyPackage.PHONE__COMMENT:
617 return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment);
618 case PartyPackage.PHONE__START:
619 return START_EDEFAULT == null ? start != null : !START_EDEFAULT.equals(start);
620 case PartyPackage.PHONE__END:
621 return END_EDEFAULT == null ? end != null : !END_EDEFAULT.equals(end);
622 case PartyPackage.PHONE__CATEGORY:
623 return CATEGORY_EDEFAULT == null ? category != null : !CATEGORY_EDEFAULT.equals(category);
624 case PartyPackage.PHONE__OWNER:
625 return getOwner() != null;
626 case PartyPackage.PHONE__COUNTRY_CODE:
627 return COUNTRY_CODE_EDEFAULT == null ? countryCode != null : !COUNTRY_CODE_EDEFAULT.equals(countryCode);
628 case PartyPackage.PHONE__AREA_CODE:
629 return areaCode != AREA_CODE_EDEFAULT;
630 case PartyPackage.PHONE__NUMBER:
631 return NUMBER_EDEFAULT == null ? number != null : !NUMBER_EDEFAULT.equals(number);
632 }
633 return super.eIsSet(featureID);
634 }
635
636 /**
637 * <!-- begin-user-doc -->
638 * <!-- end-user-doc -->
639 * @generated
640 */
641 @Override
642 public String toString() {
643 if (eIsProxy()) return super.toString();
644
645 StringBuffer result = new StringBuffer(super.toString());
646 result.append(" (comment: ");
647 result.append(comment);
648 result.append(", start: ");
649 result.append(start);
650 result.append(", end: ");
651 result.append(end);
652 result.append(", category: ");
653 result.append(category);
654 result.append(", countryCode: ");
655 result.append(countryCode);
656 result.append(", areaCode: ");
657 result.append(areaCode);
658 result.append(", number: ");
659 result.append(number);
660 result.append(')');
661 return result.toString();
662 }
663
664 } //PhoneImpl