Skip to content

Package: LibraryImpl

LibraryImpl

nameinstructionbranchcomplexitylinemethod
LibraryImpl()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
basicSetLibrarian(Librarian, NotificationChain)
M: 4 C: 25
86%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 9
90%
M: 0 C: 1
100%
eGet(int, boolean, boolean)
M: 9 C: 14
61%
M: 2 C: 4
67%
M: 2 C: 4
67%
M: 2 C: 5
71%
M: 0 C: 1
100%
eInverseAdd(InternalEObject, int, NotificationChain)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
eInverseRemove(InternalEObject, int, NotificationChain)
M: 27 C: 0
0%
M: 4 C: 0
0%
M: 4 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
eIsSet(int)
M: 22 C: 49
69%
M: 10 C: 18
64%
M: 8 C: 9
53%
M: 1 C: 6
86%
M: 0 C: 1
100%
eSet(int, Object)
M: 35 C: 7
17%
M: 5 C: 1
17%
M: 5 C: 1
17%
M: 12 C: 3
20%
M: 0 C: 1
100%
eStaticClass()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
eUnset(int)
M: 26 C: 0
0%
M: 6 C: 0
0%
M: 6 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
getBooks()
M: 0 C: 14
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getLibrarian()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getName()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPhoneNumber()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getWriters()
M: 0 C: 15
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
setLibrarian(Librarian)
M: 13 C: 39
75%
M: 3 C: 7
70%
M: 2 C: 4
67%
M: 2 C: 13
87%
M: 0 C: 1
100%
setName(String)
M: 11 C: 10
48%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 4
80%
M: 0 C: 1
100%
setPhoneNumber(String)
M: 21 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
toString()
M: 37 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
validate(DiagnosticChain, Map)
M: 0 C: 34
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 9
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: *******************************************************************************/
14: package org.eclipse.emf.ecp.view.validation.test.model.impl;
15:
16: import java.util.Collection;
17: import java.util.Map;
18:
19: import org.eclipse.emf.common.notify.Notification;
20: import org.eclipse.emf.common.notify.NotificationChain;
21: import org.eclipse.emf.common.util.BasicDiagnostic;
22: import org.eclipse.emf.common.util.Diagnostic;
23: import org.eclipse.emf.common.util.DiagnosticChain;
24: import org.eclipse.emf.common.util.EList;
25: import org.eclipse.emf.ecore.EClass;
26: import org.eclipse.emf.ecore.InternalEObject;
27: import org.eclipse.emf.ecore.impl.ENotificationImpl;
28: import org.eclipse.emf.ecore.impl.EObjectImpl;
29: import org.eclipse.emf.ecore.util.EObjectContainmentEList;
30: import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
31: import org.eclipse.emf.ecore.util.InternalEList;
32: import org.eclipse.emf.ecp.view.validation.test.model.Book;
33: import org.eclipse.emf.ecp.view.validation.test.model.Librarian;
34: import org.eclipse.emf.ecp.view.validation.test.model.Library;
35: import org.eclipse.emf.ecp.view.validation.test.model.TestPackage;
36: import org.eclipse.emf.ecp.view.validation.test.model.Writer;
37: import org.eclipse.emf.ecp.view.validation.test.model.util.TestValidator;
38:
39: /**
40: * <!-- begin-user-doc -->
41: * An implementation of the model object '<em><b>Library</b></em>'.
42: * <!-- end-user-doc -->
43: * <p>
44: * The following features are implemented:
45: * </p>
46: * <ul>
47: * <li>{@link org.eclipse.emf.ecp.view.validation.test.model.impl.LibraryImpl#getName <em>Name</em>}</li>
48: * <li>{@link org.eclipse.emf.ecp.view.validation.test.model.impl.LibraryImpl#getWriters <em>Writers</em>}</li>
49: * <li>{@link org.eclipse.emf.ecp.view.validation.test.model.impl.LibraryImpl#getBooks <em>Books</em>}</li>
50: * <li>{@link org.eclipse.emf.ecp.view.validation.test.model.impl.LibraryImpl#getLibrarian <em>Librarian</em>}</li>
51: * <li>{@link org.eclipse.emf.ecp.view.validation.test.model.impl.LibraryImpl#getPhoneNumber <em>Phone Number</em>}</li>
52: * </ul>
53: *
54: * @generated
55: */
56: public class LibraryImpl extends EObjectImpl implements Library {
57:         /**
58:          * The default value of the '{@link #getName() <em>Name</em>}' attribute.
59:          * <!-- begin-user-doc -->
60:          * <!-- end-user-doc -->
61:          *
62:          * @see #getName()
63:          * @generated
64:          * @ordered
65:          */
66:         protected static final String NAME_EDEFAULT = null;
67:
68:         /**
69:          * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
70:          * <!-- begin-user-doc -->
71:          * <!-- end-user-doc -->
72:          *
73:          * @see #getName()
74:          * @generated
75:          * @ordered
76:          */
77:         protected String name = NAME_EDEFAULT;
78:
79:         /**
80:          * The cached value of the '{@link #getWriters() <em>Writers</em>}' containment reference list.
81:          * <!-- begin-user-doc -->
82:          * <!-- end-user-doc -->
83:          *
84:          * @see #getWriters()
85:          * @generated
86:          * @ordered
87:          */
88:         protected EList<Writer> writers;
89:
90:         /**
91:          * The cached value of the '{@link #getBooks() <em>Books</em>}' containment reference list.
92:          * <!-- begin-user-doc -->
93:          * <!-- end-user-doc -->
94:          *
95:          * @see #getBooks()
96:          * @generated
97:          * @ordered
98:          */
99:         protected EList<Book> books;
100:
101:         /**
102:          * The cached value of the '{@link #getLibrarian() <em>Librarian</em>}' containment reference.
103:          * <!-- begin-user-doc -->
104:          * <!-- end-user-doc -->
105:          *
106:          * @see #getLibrarian()
107:          * @generated
108:          * @ordered
109:          */
110:         protected Librarian librarian;
111:
112:         /**
113:          * The default value of the '{@link #getPhoneNumber() <em>Phone Number</em>}' attribute.
114:          * <!-- begin-user-doc -->
115:          * <!-- end-user-doc -->
116:          *
117:          * @see #getPhoneNumber()
118:          * @generated
119:          * @ordered
120:          */
121:         protected static final String PHONE_NUMBER_EDEFAULT = null;
122:
123:         /**
124:          * The cached value of the '{@link #getPhoneNumber() <em>Phone Number</em>}' attribute.
125:          * <!-- begin-user-doc -->
126:          * <!-- end-user-doc -->
127:          *
128:          * @see #getPhoneNumber()
129:          * @generated
130:          * @ordered
131:          */
132:         protected String phoneNumber = PHONE_NUMBER_EDEFAULT;
133:
134:         /**
135:          * <!-- begin-user-doc -->
136:          * <!-- end-user-doc -->
137:          *
138:          * @generated
139:          */
140:         protected LibraryImpl() {
141:                 super();
142:         }
143:
144:         /**
145:          * <!-- begin-user-doc -->
146:          * <!-- end-user-doc -->
147:          *
148:          * @generated
149:          */
150:         @Override
151:         protected EClass eStaticClass() {
152:                 return TestPackage.Literals.LIBRARY;
153:         }
154:
155:         /**
156:          * <!-- begin-user-doc -->
157:          * <!-- end-user-doc -->
158:          *
159:          * @generated
160:          */
161:         @Override
162:         public String getName() {
163:                 return name;
164:         }
165:
166:         /**
167:          * <!-- begin-user-doc -->
168:          * <!-- end-user-doc -->
169:          *
170:          * @generated
171:          */
172:         @Override
173:         public void setName(String newName) {
174:                 final String oldName = name;
175:                 name = newName;
176:•                if (eNotificationRequired()) {
177:                         eNotify(new ENotificationImpl(this, Notification.SET, TestPackage.LIBRARY__NAME, oldName, name));
178:                 }
179:         }
180:
181:         /**
182:          * <!-- begin-user-doc -->
183:          * <!-- end-user-doc -->
184:          *
185:          * @generated
186:          */
187:         @Override
188:         public EList<Writer> getWriters() {
189:•                if (writers == null) {
190:                         writers = new EObjectContainmentWithInverseEList<Writer>(Writer.class, this, TestPackage.LIBRARY__WRITERS,
191:                                 TestPackage.WRITER__LIBRARY);
192:                 }
193:                 return writers;
194:         }
195:
196:         /**
197:          * <!-- begin-user-doc -->
198:          * <!-- end-user-doc -->
199:          *
200:          * @generated
201:          */
202:         @Override
203:         public EList<Book> getBooks() {
204:•                if (books == null) {
205:                         books = new EObjectContainmentEList<Book>(Book.class, this, TestPackage.LIBRARY__BOOKS);
206:                 }
207:                 return books;
208:         }
209:
210:         /**
211:          * <!-- begin-user-doc -->
212:          * <!-- end-user-doc -->
213:          *
214:          * @generated
215:          */
216:         @Override
217:         public Librarian getLibrarian() {
218:                 return librarian;
219:         }
220:
221:         /**
222:          * <!-- begin-user-doc -->
223:          * <!-- end-user-doc -->
224:          *
225:          * @generated
226:          */
227:         public NotificationChain basicSetLibrarian(Librarian newLibrarian, NotificationChain msgs) {
228:                 final Librarian oldLibrarian = librarian;
229:                 librarian = newLibrarian;
230:•                if (eNotificationRequired()) {
231:                         final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
232:                                 TestPackage.LIBRARY__LIBRARIAN, oldLibrarian, newLibrarian);
233:•                        if (msgs == null) {
234:                                 msgs = notification;
235:                         } else {
236:                                 msgs.add(notification);
237:                         }
238:                 }
239:                 return msgs;
240:         }
241:
242:         /**
243:          * <!-- begin-user-doc -->
244:          * <!-- end-user-doc -->
245:          *
246:          * @generated
247:          */
248:         @Override
249:         public void setLibrarian(Librarian newLibrarian) {
250:•                if (newLibrarian != librarian) {
251:                         NotificationChain msgs = null;
252:•                        if (librarian != null) {
253:                                 msgs = ((InternalEObject) librarian).eInverseRemove(this,
254:                                         EOPPOSITE_FEATURE_BASE - TestPackage.LIBRARY__LIBRARIAN, null, msgs);
255:                         }
256:•                        if (newLibrarian != null) {
257:                                 msgs = ((InternalEObject) newLibrarian).eInverseAdd(this,
258:                                         EOPPOSITE_FEATURE_BASE - TestPackage.LIBRARY__LIBRARIAN, null, msgs);
259:                         }
260:                         msgs = basicSetLibrarian(newLibrarian, msgs);
261:•                        if (msgs != null) {
262:                                 msgs.dispatch();
263:                         }
264:•                } else if (eNotificationRequired()) {
265:                         eNotify(new ENotificationImpl(this, Notification.SET, TestPackage.LIBRARY__LIBRARIAN, newLibrarian,
266:                                 newLibrarian));
267:                 }
268:         }
269:
270:         /**
271:          * <!-- begin-user-doc -->
272:          * <!-- end-user-doc -->
273:          *
274:          * @generated
275:          */
276:         @Override
277:         public String getPhoneNumber() {
278:                 return phoneNumber;
279:         }
280:
281:         /**
282:          * <!-- begin-user-doc -->
283:          * <!-- end-user-doc -->
284:          *
285:          * @generated
286:          */
287:         @Override
288:         public void setPhoneNumber(String newPhoneNumber) {
289:                 final String oldPhoneNumber = phoneNumber;
290:                 phoneNumber = newPhoneNumber;
291:•                if (eNotificationRequired()) {
292:                         eNotify(new ENotificationImpl(this, Notification.SET, TestPackage.LIBRARY__PHONE_NUMBER, oldPhoneNumber,
293:                                 phoneNumber));
294:                 }
295:         }
296:
297:         /**
298:          * <!-- begin-user-doc -->
299:          * <!-- end-user-doc -->
300:          *
301:          * @generated NOT
302:          */
303:         @Override
304:         public boolean validate(DiagnosticChain diagnostic, Map<Object, Object> context) {
305:•                if (getName() != null && getName().equals("warning")) {
306:•                        if (diagnostic != null) {
307:                                 diagnostic.add(new BasicDiagnostic(Diagnostic.WARNING,
308:                                         TestValidator.DIAGNOSTIC_SOURCE,
309:                                         TestValidator.LIBRARY__VALIDATE,
310:                                         "Name is warning.",
311:                                         new Object[] { this, TestPackage.eINSTANCE.getLibrary_Name()
312:                                         }));
313:                         }
314:                         return false;
315:                 }
316:                 return true;
317:         }
318:
319:         /**
320:          * <!-- begin-user-doc -->
321:          * <!-- end-user-doc -->
322:          *
323:          * @generated
324:          */
325:         @SuppressWarnings("unchecked")
326:         @Override
327:         public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
328:•                switch (featureID) {
329:                 case TestPackage.LIBRARY__WRITERS:
330:                         return ((InternalEList<InternalEObject>) (InternalEList<?>) getWriters()).basicAdd(otherEnd, msgs);
331:                 }
332:                 return super.eInverseAdd(otherEnd, featureID, msgs);
333:         }
334:
335:         /**
336:          * <!-- begin-user-doc -->
337:          * <!-- end-user-doc -->
338:          *
339:          * @generated
340:          */
341:         @Override
342:         public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
343:•                switch (featureID) {
344:                 case TestPackage.LIBRARY__WRITERS:
345:                         return ((InternalEList<?>) getWriters()).basicRemove(otherEnd, msgs);
346:                 case TestPackage.LIBRARY__BOOKS:
347:                         return ((InternalEList<?>) getBooks()).basicRemove(otherEnd, msgs);
348:                 case TestPackage.LIBRARY__LIBRARIAN:
349:                         return basicSetLibrarian(null, msgs);
350:                 }
351:                 return super.eInverseRemove(otherEnd, featureID, msgs);
352:         }
353:
354:         /**
355:          * <!-- begin-user-doc -->
356:          * <!-- end-user-doc -->
357:          *
358:          * @generated
359:          */
360:         @Override
361:         public Object eGet(int featureID, boolean resolve, boolean coreType) {
362:•                switch (featureID) {
363:                 case TestPackage.LIBRARY__NAME:
364:                         return getName();
365:                 case TestPackage.LIBRARY__WRITERS:
366:                         return getWriters();
367:                 case TestPackage.LIBRARY__BOOKS:
368:                         return getBooks();
369:                 case TestPackage.LIBRARY__LIBRARIAN:
370:                         return getLibrarian();
371:                 case TestPackage.LIBRARY__PHONE_NUMBER:
372:                         return getPhoneNumber();
373:                 }
374:                 return super.eGet(featureID, resolve, coreType);
375:         }
376:
377:         /**
378:          * <!-- begin-user-doc -->
379:          * <!-- end-user-doc -->
380:          *
381:          * @generated
382:          */
383:         @SuppressWarnings("unchecked")
384:         @Override
385:         public void eSet(int featureID, Object newValue) {
386:•                switch (featureID) {
387:                 case TestPackage.LIBRARY__NAME:
388:                         setName((String) newValue);
389:                         return;
390:                 case TestPackage.LIBRARY__WRITERS:
391:                         getWriters().clear();
392:                         getWriters().addAll((Collection<? extends Writer>) newValue);
393:                         return;
394:                 case TestPackage.LIBRARY__BOOKS:
395:                         getBooks().clear();
396:                         getBooks().addAll((Collection<? extends Book>) newValue);
397:                         return;
398:                 case TestPackage.LIBRARY__LIBRARIAN:
399:                         setLibrarian((Librarian) newValue);
400:                         return;
401:                 case TestPackage.LIBRARY__PHONE_NUMBER:
402:                         setPhoneNumber((String) newValue);
403:                         return;
404:                 }
405:                 super.eSet(featureID, newValue);
406:         }
407:
408:         /**
409:          * <!-- begin-user-doc -->
410:          * <!-- end-user-doc -->
411:          *
412:          * @generated
413:          */
414:         @Override
415:         public void eUnset(int featureID) {
416:•                switch (featureID) {
417:                 case TestPackage.LIBRARY__NAME:
418:                         setName(NAME_EDEFAULT);
419:                         return;
420:                 case TestPackage.LIBRARY__WRITERS:
421:                         getWriters().clear();
422:                         return;
423:                 case TestPackage.LIBRARY__BOOKS:
424:                         getBooks().clear();
425:                         return;
426:                 case TestPackage.LIBRARY__LIBRARIAN:
427:                         setLibrarian((Librarian) null);
428:                         return;
429:                 case TestPackage.LIBRARY__PHONE_NUMBER:
430:                         setPhoneNumber(PHONE_NUMBER_EDEFAULT);
431:                         return;
432:                 }
433:                 super.eUnset(featureID);
434:         }
435:
436:         /**
437:          * <!-- begin-user-doc -->
438:          * <!-- end-user-doc -->
439:          *
440:          * @generated
441:          */
442:         @Override
443:         public boolean eIsSet(int featureID) {
444:•                switch (featureID) {
445:                 case TestPackage.LIBRARY__NAME:
446:•                        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
447:                 case TestPackage.LIBRARY__WRITERS:
448:•                        return writers != null && !writers.isEmpty();
449:                 case TestPackage.LIBRARY__BOOKS:
450:•                        return books != null && !books.isEmpty();
451:                 case TestPackage.LIBRARY__LIBRARIAN:
452:•                        return librarian != null;
453:                 case TestPackage.LIBRARY__PHONE_NUMBER:
454:•                        return PHONE_NUMBER_EDEFAULT == null ? phoneNumber != null : !PHONE_NUMBER_EDEFAULT.equals(phoneNumber);
455:                 }
456:                 return super.eIsSet(featureID);
457:         }
458:
459:         /**
460:          * <!-- begin-user-doc -->
461:          * <!-- end-user-doc -->
462:          *
463:          * @generated
464:          */
465:         @Override
466:         public String toString() {
467:•                if (eIsProxy()) {
468:                         return super.toString();
469:                 }
470:
471:                 final StringBuffer result = new StringBuffer(super.toString());
472:                 result.append(" (name: ");
473:                 result.append(name);
474:                 result.append(", phoneNumber: ");
475:                 result.append(phoneNumber);
476:                 result.append(')');
477:                 return result.toString();
478:         }
479:
480: } // LibraryImpl