blob: 4f04ed2f68a61a2953efe2fb56b83d827257c198 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008-2011 Chair for Applied Software Engineering,
* Technische Universitaet Muenchen.
* 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:
******************************************************************************/
package org.eclipse.emf.emfstore.internal.common.model.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.emfstore.internal.common.model.ModelPackage;
import org.eclipse.emf.emfstore.internal.common.model.UniqueIdentifier;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Unique Identifier</b></em>'. <!-- end-user-doc
* -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.emfstore.internal.common.model.impl.UniqueIdentifierImpl#getId <em>Id</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class UniqueIdentifierImpl extends EObjectImpl implements UniqueIdentifier {
/**
* The default value of the '{@link #getId() <em>Id</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getId()
* @generated
* @ordered
*/
protected static final String ID_EDEFAULT = "Default Value Literal\t"; //$NON-NLS-1$
/**
* The cached value of the '{@link #getId() <em>Id</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getId()
* @generated
* @ordered
*/
protected String id = ID_EDEFAULT;
// begin of custom code
/**
* Constructor. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
protected UniqueIdentifierImpl() {
super();
id = EcoreUtil.generateUUID();
}
// end of custom code
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ModelPackage.Literals.UNIQUE_IDENTIFIER;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public String getId() {
return id;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setId(String newId) {
final String oldId = id;
id = newId;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.UNIQUE_IDENTIFIER__ID, oldId, id));
}
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ModelPackage.UNIQUE_IDENTIFIER__ID:
return getId();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ModelPackage.UNIQUE_IDENTIFIER__ID:
setId((String) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ModelPackage.UNIQUE_IDENTIFIER__ID:
setId(ID_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ModelPackage.UNIQUE_IDENTIFIER__ID:
return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
}
return super.eIsSet(featureID);
}
// begin of custom code
/**
* <!-- begin-user-doc --> Returns a string representation.
*
* @return the string <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String toString() {
if (eIsProxy()) {
return super.toString();
}
final StringBuffer result = new StringBuffer();
result.append(" (id: "); //$NON-NLS-1$
result.append(id);
result.append(')');
return result.toString();
}
/**
* Returns true if the two identifiers are identical. False in any other case.
*
* @param otherObject the other object
* @return true if the two object are considered equal
* @see java.lang.Object#equals(java.lang.Object)
* @generated NOT
*/
@Override
public boolean equals(Object otherObject) {
if (otherObject instanceof UniqueIdentifierImpl) {
final UniqueIdentifierImpl otherUniqueIdentifier = (UniqueIdentifierImpl) otherObject;
return otherUniqueIdentifier.id.equals(id);
} else if (otherObject instanceof String) {
return id.equals(otherObject);
} else {
return false;
}
}
/**
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return id.hashCode();
}
// end of custom code
} // UniqueIdentifierImpl