001 /** 002 * <copyright> 003 * </copyright> 004 * 005 * $Id$ 006 */ 007 package com.hammurapi.review.impl; 008 009 import java.util.Collection; 010 011 import org.eclipse.emf.common.notify.Notification; 012 import org.eclipse.emf.common.notify.NotificationChain; 013 import org.eclipse.emf.common.util.EList; 014 import org.eclipse.emf.ecore.EClass; 015 import org.eclipse.emf.ecore.InternalEObject; 016 import org.eclipse.emf.ecore.impl.ENotificationImpl; 017 import org.eclipse.emf.ecore.impl.EObjectImpl; 018 import org.eclipse.emf.ecore.util.EObjectContainmentEList; 019 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; 020 import org.eclipse.emf.ecore.util.InternalEList; 021 022 import com.hammurapi.review.Baseline; 023 import com.hammurapi.review.Report; 024 import com.hammurapi.review.ReviewPackage; 025 import com.hammurapi.review.Revision; 026 027 /** 028 * <!-- begin-user-doc --> 029 * An implementation of the model object '<em><b>Baseline</b></em>'. 030 * <!-- end-user-doc --> 031 * <p> 032 * The following features are implemented: 033 * <ul> 034 * <li>{@link com.hammurapi.review.impl.BaselineImpl#getRoots <em>Roots</em>}</li> 035 * <li>{@link com.hammurapi.review.impl.BaselineImpl#getTimestamp <em>Timestamp</em>}</li> 036 * <li>{@link com.hammurapi.review.impl.BaselineImpl#getDescription <em>Description</em>}</li> 037 * <li>{@link com.hammurapi.review.impl.BaselineImpl#getReports <em>Reports</em>}</li> 038 * </ul> 039 * </p> 040 * 041 * @generated 042 */ 043 public class BaselineImpl extends EObjectImpl implements Baseline { 044 /** 045 * The cached value of the '{@link #getRoots() <em>Roots</em>}' containment reference list. 046 * <!-- begin-user-doc --> 047 * <!-- end-user-doc --> 048 * @see #getRoots() 049 * @generated 050 * @ordered 051 */ 052 protected EList<Revision> roots; 053 054 /** 055 * The default value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute. 056 * <!-- begin-user-doc --> 057 * <!-- end-user-doc --> 058 * @see #getTimestamp() 059 * @generated 060 * @ordered 061 */ 062 protected static final long TIMESTAMP_EDEFAULT = 0L; 063 064 /** 065 * The cached value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute. 066 * <!-- begin-user-doc --> 067 * <!-- end-user-doc --> 068 * @see #getTimestamp() 069 * @generated 070 * @ordered 071 */ 072 protected long timestamp = TIMESTAMP_EDEFAULT; 073 074 /** 075 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute. 076 * <!-- begin-user-doc --> 077 * <!-- end-user-doc --> 078 * @see #getDescription() 079 * @generated 080 * @ordered 081 */ 082 protected static final String DESCRIPTION_EDEFAULT = null; 083 084 /** 085 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute. 086 * <!-- begin-user-doc --> 087 * <!-- end-user-doc --> 088 * @see #getDescription() 089 * @generated 090 * @ordered 091 */ 092 protected String description = DESCRIPTION_EDEFAULT; 093 094 /** 095 * The cached value of the '{@link #getReports() <em>Reports</em>}' containment reference list. 096 * <!-- begin-user-doc --> 097 * <!-- end-user-doc --> 098 * @see #getReports() 099 * @generated 100 * @ordered 101 */ 102 protected EList<Report> reports; 103 104 /** 105 * <!-- begin-user-doc --> 106 * <!-- end-user-doc --> 107 * @generated 108 */ 109 protected BaselineImpl() { 110 super(); 111 } 112 113 /** 114 * <!-- begin-user-doc --> 115 * <!-- end-user-doc --> 116 * @generated 117 */ 118 @Override 119 protected EClass eStaticClass() { 120 return ReviewPackage.Literals.BASELINE; 121 } 122 123 /** 124 * <!-- begin-user-doc --> 125 * <!-- end-user-doc --> 126 * @generated 127 */ 128 public EList<Revision> getRoots() { 129 if (roots == null) { 130 roots = new EObjectContainmentEList<Revision>(Revision.class, this, ReviewPackage.BASELINE__ROOTS); 131 } 132 return roots; 133 } 134 135 /** 136 * <!-- begin-user-doc --> 137 * <!-- end-user-doc --> 138 * @generated 139 */ 140 public long getTimestamp() { 141 return timestamp; 142 } 143 144 /** 145 * <!-- begin-user-doc --> 146 * <!-- end-user-doc --> 147 * @generated 148 */ 149 public void setTimestamp(long newTimestamp) { 150 long oldTimestamp = timestamp; 151 timestamp = newTimestamp; 152 if (eNotificationRequired()) 153 eNotify(new ENotificationImpl(this, Notification.SET, ReviewPackage.BASELINE__TIMESTAMP, oldTimestamp, timestamp)); 154 } 155 156 /** 157 * <!-- begin-user-doc --> 158 * <!-- end-user-doc --> 159 * @generated 160 */ 161 public String getDescription() { 162 return description; 163 } 164 165 /** 166 * <!-- begin-user-doc --> 167 * <!-- end-user-doc --> 168 * @generated 169 */ 170 public void setDescription(String newDescription) { 171 String oldDescription = description; 172 description = newDescription; 173 if (eNotificationRequired()) 174 eNotify(new ENotificationImpl(this, Notification.SET, ReviewPackage.BASELINE__DESCRIPTION, oldDescription, description)); 175 } 176 177 /** 178 * <!-- begin-user-doc --> 179 * <!-- end-user-doc --> 180 * @generated 181 */ 182 public EList<Report> getReports() { 183 if (reports == null) { 184 reports = new EObjectContainmentWithInverseEList<Report>(Report.class, this, ReviewPackage.BASELINE__REPORTS, ReviewPackage.REPORT__BASELINE); 185 } 186 return reports; 187 } 188 189 /** 190 * <!-- begin-user-doc --> 191 * <!-- end-user-doc --> 192 * @generated 193 */ 194 @SuppressWarnings("unchecked") 195 @Override 196 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 197 switch (featureID) { 198 case ReviewPackage.BASELINE__REPORTS: 199 return ((InternalEList<InternalEObject>)(InternalEList<?>)getReports()).basicAdd(otherEnd, msgs); 200 } 201 return super.eInverseAdd(otherEnd, featureID, msgs); 202 } 203 204 /** 205 * <!-- begin-user-doc --> 206 * <!-- end-user-doc --> 207 * @generated 208 */ 209 @Override 210 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 211 switch (featureID) { 212 case ReviewPackage.BASELINE__ROOTS: 213 return ((InternalEList<?>)getRoots()).basicRemove(otherEnd, msgs); 214 case ReviewPackage.BASELINE__REPORTS: 215 return ((InternalEList<?>)getReports()).basicRemove(otherEnd, msgs); 216 } 217 return super.eInverseRemove(otherEnd, featureID, msgs); 218 } 219 220 /** 221 * <!-- begin-user-doc --> 222 * <!-- end-user-doc --> 223 * @generated 224 */ 225 @Override 226 public Object eGet(int featureID, boolean resolve, boolean coreType) { 227 switch (featureID) { 228 case ReviewPackage.BASELINE__ROOTS: 229 return getRoots(); 230 case ReviewPackage.BASELINE__TIMESTAMP: 231 return getTimestamp(); 232 case ReviewPackage.BASELINE__DESCRIPTION: 233 return getDescription(); 234 case ReviewPackage.BASELINE__REPORTS: 235 return getReports(); 236 } 237 return super.eGet(featureID, resolve, coreType); 238 } 239 240 /** 241 * <!-- begin-user-doc --> 242 * <!-- end-user-doc --> 243 * @generated 244 */ 245 @SuppressWarnings("unchecked") 246 @Override 247 public void eSet(int featureID, Object newValue) { 248 switch (featureID) { 249 case ReviewPackage.BASELINE__ROOTS: 250 getRoots().clear(); 251 getRoots().addAll((Collection<? extends Revision>)newValue); 252 return; 253 case ReviewPackage.BASELINE__TIMESTAMP: 254 setTimestamp((Long)newValue); 255 return; 256 case ReviewPackage.BASELINE__DESCRIPTION: 257 setDescription((String)newValue); 258 return; 259 case ReviewPackage.BASELINE__REPORTS: 260 getReports().clear(); 261 getReports().addAll((Collection<? extends Report>)newValue); 262 return; 263 } 264 super.eSet(featureID, newValue); 265 } 266 267 /** 268 * <!-- begin-user-doc --> 269 * <!-- end-user-doc --> 270 * @generated 271 */ 272 @Override 273 public void eUnset(int featureID) { 274 switch (featureID) { 275 case ReviewPackage.BASELINE__ROOTS: 276 getRoots().clear(); 277 return; 278 case ReviewPackage.BASELINE__TIMESTAMP: 279 setTimestamp(TIMESTAMP_EDEFAULT); 280 return; 281 case ReviewPackage.BASELINE__DESCRIPTION: 282 setDescription(DESCRIPTION_EDEFAULT); 283 return; 284 case ReviewPackage.BASELINE__REPORTS: 285 getReports().clear(); 286 return; 287 } 288 super.eUnset(featureID); 289 } 290 291 /** 292 * <!-- begin-user-doc --> 293 * <!-- end-user-doc --> 294 * @generated 295 */ 296 @Override 297 public boolean eIsSet(int featureID) { 298 switch (featureID) { 299 case ReviewPackage.BASELINE__ROOTS: 300 return roots != null && !roots.isEmpty(); 301 case ReviewPackage.BASELINE__TIMESTAMP: 302 return timestamp != TIMESTAMP_EDEFAULT; 303 case ReviewPackage.BASELINE__DESCRIPTION: 304 return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description); 305 case ReviewPackage.BASELINE__REPORTS: 306 return reports != null && !reports.isEmpty(); 307 } 308 return super.eIsSet(featureID); 309 } 310 311 /** 312 * <!-- begin-user-doc --> 313 * <!-- end-user-doc --> 314 * @generated 315 */ 316 @Override 317 public String toString() { 318 if (eIsProxy()) return super.toString(); 319 320 StringBuffer result = new StringBuffer(super.toString()); 321 result.append(" (timestamp: "); 322 result.append(timestamp); 323 result.append(", description: "); 324 result.append(description); 325 result.append(')'); 326 return result.toString(); 327 } 328 329 } //BaselineImpl