/**
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright (C) 2007 Matthias Braeuer (braeuer.matthias@web.de). *
* All rights reserved. *
* *
* This work was done as a project at the Chair for Software Technology, *
* Dresden University Of Technology, Germany (http://st.inf.tu-dresden.de). *
* It is understood that any modification not identified as such is not *
* covered by the preceding statement. *
* *
* This work is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Library General Public License as published *
* by the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This work is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public *
* License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; if not, you can view it online at *
* http://www.fsf.org/licensing/licenses/gpl.html. *
* *
* To submit a bug report, send a comment, or get the latest news on this *
* project, please visit the website: http://dresden-ocl.sourceforge.net. *
* For more information on OCL and related projects visit the OCL Portal: *
* http://st.inf.tu-dresden.de/ocl *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* $Id$
*/
package org.dresdenocl.pivotmodel.impl;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.dresdenocl.pivotmodel.NamedElement;
import org.dresdenocl.pivotmodel.PivotModelFactory;
import org.dresdenocl.pivotmodel.PivotModelPackage;
import org.dresdenocl.pivotmodel.Property;
import org.dresdenocl.pivotmodel.Type;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Property</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.dresdenocl.pivotmodel.impl.PropertyImpl#getOwningType <em>Owning Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PropertyImpl extends FeatureImpl implements Property {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(PropertyImpl.class);
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected PropertyImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return PivotModelPackage.Literals.PROPERTY;
}
/**
* Overridden to return the {@link #getOwningType() owning type} of this
* <code>Property</code>.
*
* @see org.dresdenocl.pivotmodel.impl.NamedElementImpl#getOwner()
*/
@Override
public NamedElement getOwner() {
return getOwningType();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Type getOwningType() {
if (eContainerFeatureID() != PivotModelPackage.PROPERTY__OWNING_TYPE)
return null;
return (Type) eInternalContainer();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwningType(Type newOwningType,
NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newOwningType,
PivotModelPackage.PROPERTY__OWNING_TYPE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwningType(Type newOwningType) {
if (newOwningType != eInternalContainer()
|| (eContainerFeatureID() != PivotModelPackage.PROPERTY__OWNING_TYPE && newOwningType != null)) {
if (EcoreUtil.isAncestor(this, newOwningType))
throw new IllegalArgumentException(
"Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newOwningType != null)
msgs = ((InternalEObject) newOwningType).eInverseAdd(this,
PivotModelPackage.TYPE__OWNED_PROPERTY, Type.class,
msgs);
msgs = basicSetOwningType(newOwningType, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
PivotModelPackage.PROPERTY__OWNING_TYPE, newOwningType,
newOwningType));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public boolean isIdentifier() {
return false;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public boolean cmpSlots(Property p) {
if (logger.isDebugEnabled()) {
logger.debug("cmpSlots(p=" + p + ") - enter"); //$NON-NLS-1$ //$NON-NLS-2$
}
boolean result;
// compare name and type (note that we require the type of the property
// to be non-null)
result = getName().equals(p.getName()) && getType() != null
&& getType().equals(p.getType());
if (logger.isDebugEnabled()) {
logger.debug("cmpSlots() - exit - return value=" + result); //$NON-NLS-1$
}
return result;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public Property clone() {
return initialize(PivotModelFactory.eINSTANCE.createProperty());
}
/**
* Helper method that initializes this <code>Property</code>.
*
* @see org.dresdenocl.pivotmodel.impl.FeatureImpl#initialize(org.dresdenocl.pivotmodel.Feature)
*/
protected Property initialize(Property clone) {
super.initialize(clone);
return clone;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case PivotModelPackage.PROPERTY__OWNING_TYPE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwningType((Type) otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case PivotModelPackage.PROPERTY__OWNING_TYPE:
return basicSetOwningType(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(
NotificationChain msgs) {
switch (eContainerFeatureID()) {
case PivotModelPackage.PROPERTY__OWNING_TYPE:
return eInternalContainer().eInverseRemove(this,
PivotModelPackage.TYPE__OWNED_PROPERTY, Type.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case PivotModelPackage.PROPERTY__OWNING_TYPE:
return getOwningType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case PivotModelPackage.PROPERTY__OWNING_TYPE:
setOwningType((Type) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case PivotModelPackage.PROPERTY__OWNING_TYPE:
setOwningType((Type) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case PivotModelPackage.PROPERTY__OWNING_TYPE:
return getOwningType() != null;
}
return super.eIsSet(featureID);
}
/**
* Adapted for a consistent appearance.
*
* @generated NOT
*/
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.appendToString(super.toString()).toString();
}
} // PropertyImpl