📄 libraryimpl.java
字号:
/**
* <copyright>
*
* Copyright (c) 2005 IBM Corporation 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:
* IBM - Initial API and implementation
*
* </copyright>
*
* $Id: LibraryImpl.java,v 1.4 2006/04/03 18:00:31 emerks Exp $
*/
package org.eclipse.emf.examples.extlibrary.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EObjectEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.examples.extlibrary.Book;
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
import org.eclipse.emf.examples.extlibrary.Item;
import org.eclipse.emf.examples.extlibrary.Library;
//import org.eclipse.emf.ecore.util.EObjectResolvingEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Library</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getAddress <em>Address</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getWriters <em>Writers</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getEmployees <em>Employees</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getBorrowers <em>Borrowers</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getStock <em>Stock</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getBooks <em>Books</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getBranches <em>Branches</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getParentBranch <em>Parent Branch</em>}</li>
* <li>{@link org.eclipse.emf.examples.extlibrary.impl.LibraryImpl#getPeople <em>People</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class LibraryImpl extends EObjectImpl implements Library
{
/**
* The default value of the '{@link #getAddress() <em>Address</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAddress()
* @generated
* @ordered
*/
protected static final String ADDRESS_EDEFAULT = null;
/**
* The cached value of the '{@link #getAddress() <em>Address</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAddress()
* @generated
* @ordered
*/
protected String address = ADDRESS_EDEFAULT;
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getStock() <em>Stock</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getStock()
* @generated
* @ordered
*/
protected EList stock = null;
/**
* The cached value of the '{@link #getBooks() <em>Books</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBooks()
* @generated
* @ordered
*/
protected EList books = null;
/**
* The cached value of the '{@link #getBranches() <em>Branches</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBranches()
* @generated
* @ordered
*/
protected EList branches = null;
/**
* The cached value of the '{@link #getPeople() <em>People</em>}' attribute list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPeople()
* @generated
* @ordered
*/
protected FeatureMap people = null;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected LibraryImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass()
{
return EXTLibraryPackage.Literals.LIBRARY;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getAddress()
{
return address;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAddress(String newAddress)
{
String oldAddress = address;
address = newAddress;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EXTLibraryPackage.LIBRARY__ADDRESS, oldAddress, address));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName()
{
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName)
{
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EXTLibraryPackage.LIBRARY__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getWriters()
{
return ((FeatureMap)getPeople()).list(EXTLibraryPackage.Literals.LIBRARY__WRITERS);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getEmployees()
{
return ((FeatureMap)getPeople()).list(EXTLibraryPackage.Literals.LIBRARY__EMPLOYEES);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getBorrowers()
{
return ((FeatureMap)getPeople()).list(EXTLibraryPackage.Literals.LIBRARY__BORROWERS);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public EList getStock()
{
if (stock == null)
{
// create a custom list implementation that synchronizes its book
// content with the "books" subset
stock = new EObjectContainmentEList(Item.class, this, EXTLibraryPackage.LIBRARY__STOCK)
{
private static final long serialVersionUID = 1L;
protected void didAdd(int index, Object newObject)
{
if ((newObject instanceof Book) && !getBooks().contains(newObject))
{
// these lists are unordered, so index doesn't matter
getBooks().add(newObject);
}
}
protected void didRemove(int index, Object oldObject)
{
if ((oldObject instanceof Book) && getBooks().contains(oldObject))
{
// these lists are unordered, so index doesn't matter
getBooks().remove(oldObject);
}
}
protected void didSet(int index, Object newObject, Object oldObject)
{
didRemove(index, oldObject);
didAdd(index, newObject);
}
};
}
return stock;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public EList getBooks()
{
if (books == null)
{
// create a custom list implementation that synchronizes its content
// with the "stock" superset
books = new EObjectEList(Book.class, this, EXTLibraryPackage.LIBRARY__BOOKS)
{
private static final long serialVersionUID = 1L;
protected void didAdd(int index, Object newObject)
{
if (getStock().indexOf(newObject) == -1)
{
// these lists are unordered, so index doesn't matter
getStock().add(newObject);
}
}
protected void didRemove(int index, Object oldObject)
{
if (getStock().indexOf(oldObject) != -1)
{
// these lists are unordered, so index doesn't matter
getStock().remove(oldObject);
}
}
protected void didSet(int index, Object newObject, Object oldObject)
{
didRemove(index, oldObject);
didAdd(index, newObject);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -