| /******************************************************************************* |
| * Copyright (c) 2013, 2018 CEA LIST and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * E.D.Willink (CEA LIST) - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ocl.examples.emf.validation.validity.impl; |
| |
| import java.util.Collection; |
| |
| 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.MinimalEObjectImpl; |
| import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.examples.emf.validation.validity.Result; |
| import org.eclipse.ocl.examples.emf.validation.validity.ResultSet; |
| import org.eclipse.ocl.examples.emf.validation.validity.RootNode; |
| import org.eclipse.ocl.examples.emf.validation.validity.ValidityPackage; |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Result Set</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.examples.emf.validation.validity.impl.ResultSetImpl#getRoot <em>Root</em>}</li> |
| * <li>{@link org.eclipse.ocl.examples.emf.validation.validity.impl.ResultSetImpl#getResults <em>Results</em>}</li> |
| * <li>{@link org.eclipse.ocl.examples.emf.validation.validity.impl.ResultSetImpl#getTimestamp <em>Timestamp</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ResultSetImpl extends MinimalEObjectImpl.Container implements ResultSet { |
| /** |
| * The cached value of the '{@link #getResults() <em>Results</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getResults() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Result> results; |
| |
| /** |
| * The default value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTimestamp() |
| * @generated |
| * @ordered |
| */ |
| protected static final String TIMESTAMP_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getTimestamp() <em>Timestamp</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTimestamp() |
| * @generated |
| * @ordered |
| */ |
| protected String timestamp = TIMESTAMP_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ResultSetImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return ValidityPackage.Literals.RESULT_SET; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public RootNode getRoot() { |
| if (eContainerFeatureID() != ValidityPackage.RESULT_SET__ROOT) return null; |
| return (RootNode)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetRoot(RootNode newRoot, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newRoot, ValidityPackage.RESULT_SET__ROOT, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setRoot(RootNode newRoot) { |
| if (newRoot != eInternalContainer() || (eContainerFeatureID() != ValidityPackage.RESULT_SET__ROOT && newRoot != null)) { |
| if (EcoreUtil.isAncestor(this, newRoot)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newRoot != null) |
| msgs = ((InternalEObject)newRoot).eInverseAdd(this, ValidityPackage.ROOT_NODE__RESULT_SETS, RootNode.class, msgs); |
| msgs = basicSetRoot(newRoot, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT // Bug 414352 workaround |
| */ |
| @Override |
| @SuppressWarnings("null") |
| public @NonNull EList<Result> getResults() { |
| if (results == null) { |
| results = new EObjectContainmentWithInverseEList<Result>(Result.class, this, ValidityPackage.RESULT_SET__RESULTS, ValidityPackage.RESULT__RESULT_SET); |
| } |
| return results; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getTimestamp() { |
| return timestamp; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setTimestamp(String newTimestamp) { |
| timestamp = newTimestamp; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case ValidityPackage.RESULT_SET__ROOT: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetRoot((RootNode)otherEnd, msgs); |
| case ValidityPackage.RESULT_SET__RESULTS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getResults()).basicAdd(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 ValidityPackage.RESULT_SET__ROOT: |
| return basicSetRoot(null, msgs); |
| case ValidityPackage.RESULT_SET__RESULTS: |
| return ((InternalEList<?>)getResults()).basicRemove(otherEnd, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case ValidityPackage.RESULT_SET__ROOT: |
| return eInternalContainer().eInverseRemove(this, ValidityPackage.ROOT_NODE__RESULT_SETS, RootNode.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 ValidityPackage.RESULT_SET__ROOT: |
| return getRoot(); |
| case ValidityPackage.RESULT_SET__RESULTS: |
| return getResults(); |
| case ValidityPackage.RESULT_SET__TIMESTAMP: |
| return getTimestamp(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case ValidityPackage.RESULT_SET__ROOT: |
| setRoot((RootNode)newValue); |
| return; |
| case ValidityPackage.RESULT_SET__RESULTS: |
| getResults().clear(); |
| getResults().addAll((Collection<? extends Result>)newValue); |
| return; |
| case ValidityPackage.RESULT_SET__TIMESTAMP: |
| setTimestamp((String)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case ValidityPackage.RESULT_SET__ROOT: |
| setRoot((RootNode)null); |
| return; |
| case ValidityPackage.RESULT_SET__RESULTS: |
| getResults().clear(); |
| return; |
| case ValidityPackage.RESULT_SET__TIMESTAMP: |
| setTimestamp(TIMESTAMP_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case ValidityPackage.RESULT_SET__ROOT: |
| return getRoot() != null; |
| case ValidityPackage.RESULT_SET__RESULTS: |
| return results != null && !results.isEmpty(); |
| case ValidityPackage.RESULT_SET__TIMESTAMP: |
| return TIMESTAMP_EDEFAULT == null ? timestamp != null : !TIMESTAMP_EDEFAULT.equals(timestamp); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (timestamp: "); |
| result.append(timestamp); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ResultSetImpl |