blob: 0de09f697fd2b27f1351204dbf1f31678e7c8be0 [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2014-2015 itemis 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:
* itemis - Initial API and implementation
*
* </copyright>
*/
package org.eclipse.sphinx.emf.check.catalog.impl;
import java.lang.reflect.InvocationTargetException;
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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.sphinx.emf.check.catalog.Catalog;
import org.eclipse.sphinx.emf.check.catalog.Category;
import org.eclipse.sphinx.emf.check.catalog.CheckCatalogPackage;
import org.eclipse.sphinx.emf.check.catalog.Constraint;
import org.eclipse.sphinx.emf.check.catalog.Severity;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Catalog</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.sphinx.emf.check.catalog.impl.CatalogImpl#getCategories <em>Categories</em>}</li>
* <li>{@link org.eclipse.sphinx.emf.check.catalog.impl.CatalogImpl#getConstraints <em>Constraints</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class CatalogImpl extends IdentifiableImpl implements Catalog {
/**
* The cached value of the '{@link #getCategories() <em>Categories</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCategories()
* @generated
* @ordered
*/
protected EList<Category> categories;
/**
* The cached value of the '{@link #getConstraints() <em>Constraints</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getConstraints()
* @generated
* @ordered
*/
protected EList<Constraint> constraints;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CatalogImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CheckCatalogPackage.Literals.CATALOG;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Category> getCategories() {
if (categories == null) {
categories = new EObjectContainmentEList<Category>(Category.class, this, CheckCatalogPackage.CATALOG__CATEGORIES);
}
return categories;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Constraint> getConstraints() {
if (constraints == null) {
constraints = new EObjectContainmentEList<Constraint>(Constraint.class, this, CheckCatalogPackage.CATALOG__CONSTRAINTS);
}
return constraints;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getMessage(final String constraintId) {
for (Constraint constraint : getConstraints()) {
String id = constraint.getId();
if (id != null && id.equals(constraintId)) {
return constraint.getMessage();
}
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Severity getSeverity(final String constraintId) {
for (Constraint contraint : getConstraints()) {
String id = contraint.getId();
if (id != null && id.equals(constraintId)) {
return contraint.getSeverity();
}
}
return Severity.ERROR;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CheckCatalogPackage.CATALOG__CATEGORIES:
return ((InternalEList<?>)getCategories()).basicRemove(otherEnd, msgs);
case CheckCatalogPackage.CATALOG__CONSTRAINTS:
return ((InternalEList<?>)getConstraints()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case CheckCatalogPackage.CATALOG__CATEGORIES:
return getCategories();
case CheckCatalogPackage.CATALOG__CONSTRAINTS:
return getConstraints();
}
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 CheckCatalogPackage.CATALOG__CATEGORIES:
getCategories().clear();
getCategories().addAll((Collection<? extends Category>)newValue);
return;
case CheckCatalogPackage.CATALOG__CONSTRAINTS:
getConstraints().clear();
getConstraints().addAll((Collection<? extends Constraint>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CheckCatalogPackage.CATALOG__CATEGORIES:
getCategories().clear();
return;
case CheckCatalogPackage.CATALOG__CONSTRAINTS:
getConstraints().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CheckCatalogPackage.CATALOG__CATEGORIES:
return categories != null && !categories.isEmpty();
case CheckCatalogPackage.CATALOG__CONSTRAINTS:
return constraints != null && !constraints.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
case CheckCatalogPackage.CATALOG___GET_MESSAGE__STRING:
return getMessage((String)arguments.get(0));
case CheckCatalogPackage.CATALOG___GET_SEVERITY__STRING:
return getSeverity((String)arguments.get(0));
}
return super.eInvoke(operationID, arguments);
}
} //CatalogImpl