blob: 049b59c4d96e0a2e1ed9829499afa98d1f4aad8d [file] [log] [blame]
package org.eclipse.stem.core.model.impl;
/*******************************************************************************
* Copyright (c) 2006 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 Corporation - initial API and implementation
*******************************************************************************/
import java.util.Calendar;
import java.util.Date;
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.stem.core.model.ModelFactory;
import org.eclipse.stem.core.model.ModelPackage;
import org.eclipse.stem.core.model.STEMTime;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>STEM Time</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.stem.core.model.impl.STEMTimeImpl#getTime <em>Time</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class STEMTimeImpl extends EObjectImpl implements STEMTime {
/**
* The default value of the '{@link #getTime() <em>Time</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getTime()
* @generated
* @ordered
*/
protected static final Date TIME_EDEFAULT = null;
/**
* The cached value of the '{@link #getTime() <em>Time</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getTime()
* @generated
* @ordered
*/
protected Date time = TIME_EDEFAULT;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
protected STEMTimeImpl() {
super();
// Set the default time to the current time.
setTime(Calendar.getInstance().getTime());
} // STEMTimeImpl
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ModelPackage.Literals.STEM_TIME;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated NOT
*/
public Date getTime() {
return (Date)time.clone();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated NOT
*/
public void setTime(Date newTime) {
Date oldTime = time;
time = (Date)newTime.clone();
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.STEM_TIME__TIME, oldTime, time));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
public STEMTime addIncrement(long timeIncrement) {
final STEMTime retValue = ModelFactory.eINSTANCE.createSTEMTime();
final long newTime = getTime().getTime() + timeIncrement;
final Date newDate = new Date(newTime);
retValue.setTime(newDate);
return retValue;
} // addIncrement
/**
* compares STEMTimes
*
*/
public int compareTo(STEMTime otherTime) {
return getTime().compareTo(otherTime.getTime());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public boolean valueEquals(STEMTime obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (time == null) {
if (obj.getTime() != null)
return false;
} else if (!time.equals(obj.getTime()))
return false;
return true;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ModelPackage.STEM_TIME__TIME:
return getTime();
}
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.STEM_TIME__TIME:
setTime((Date)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ModelPackage.STEM_TIME__TIME:
setTime(TIME_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ModelPackage.STEM_TIME__TIME:
return TIME_EDEFAULT == null ? time != null : !TIME_EDEFAULT.equals(time);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
public String toString() {
if (eIsProxy())
return super.toString();
// StringBuffer result = new StringBuffer(super.toString());
// result.append(" (time: ");
// result.append(time);
// result.append(')');
return time.toString();
} // toString
} // STEMTimeImpl