| /** |
| * <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 v2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| * |
| * Contributors: |
| * itemis - Initial API and implementation |
| * |
| * </copyright> |
| */ |
| package org.eclipse.sphinx.emf.check.catalog.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| |
| import org.eclipse.emf.common.util.EList; |
| |
| import org.eclipse.emf.ecore.EClass; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
| |
| 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>Constraint</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.sphinx.emf.check.catalog.impl.ConstraintImpl#getSeverity <em>Severity</em>}</li> |
| * <li>{@link org.eclipse.sphinx.emf.check.catalog.impl.ConstraintImpl#getMessage <em>Message</em>}</li> |
| * <li>{@link org.eclipse.sphinx.emf.check.catalog.impl.ConstraintImpl#getCategories <em>Categories</em>}</li> |
| * <li>{@link org.eclipse.sphinx.emf.check.catalog.impl.ConstraintImpl#getComment <em>Comment</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class ConstraintImpl extends IdentifiableImpl implements Constraint { |
| /** |
| * The default value of the '{@link #getSeverity() <em>Severity</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSeverity() |
| * @generated |
| * @ordered |
| */ |
| protected static final Severity SEVERITY_EDEFAULT = Severity.ERROR; |
| |
| /** |
| * The cached value of the '{@link #getSeverity() <em>Severity</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSeverity() |
| * @generated |
| * @ordered |
| */ |
| protected Severity severity = SEVERITY_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getMessage() <em>Message</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getMessage() |
| * @generated |
| * @ordered |
| */ |
| protected static final String MESSAGE_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getMessage() <em>Message</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getMessage() |
| * @generated |
| * @ordered |
| */ |
| protected String message = MESSAGE_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getCategories() <em>Categories</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getCategories() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Category> categories; |
| |
| /** |
| * The default value of the '{@link #getComment() <em>Comment</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getComment() |
| * @generated |
| * @ordered |
| */ |
| protected static final String COMMENT_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getComment() <em>Comment</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getComment() |
| * @generated |
| * @ordered |
| */ |
| protected String comment = COMMENT_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ConstraintImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return CheckCatalogPackage.Literals.CONSTRAINT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Severity getSeverity() { |
| return severity; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setSeverity(Severity newSeverity) { |
| Severity oldSeverity = severity; |
| severity = newSeverity == null ? SEVERITY_EDEFAULT : newSeverity; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CheckCatalogPackage.CONSTRAINT__SEVERITY, oldSeverity, severity)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getMessage() { |
| return message; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setMessage(String newMessage) { |
| String oldMessage = message; |
| message = newMessage; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CheckCatalogPackage.CONSTRAINT__MESSAGE, oldMessage, message)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Category> getCategories() { |
| if (categories == null) { |
| categories = new EObjectResolvingEList<Category>(Category.class, this, CheckCatalogPackage.CONSTRAINT__CATEGORIES); |
| } |
| return categories; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getComment() { |
| return comment; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setComment(String newComment) { |
| String oldComment = comment; |
| comment = newComment; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CheckCatalogPackage.CONSTRAINT__COMMENT, oldComment, comment)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case CheckCatalogPackage.CONSTRAINT__SEVERITY: |
| return getSeverity(); |
| case CheckCatalogPackage.CONSTRAINT__MESSAGE: |
| return getMessage(); |
| case CheckCatalogPackage.CONSTRAINT__CATEGORIES: |
| return getCategories(); |
| case CheckCatalogPackage.CONSTRAINT__COMMENT: |
| return getComment(); |
| } |
| 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.CONSTRAINT__SEVERITY: |
| setSeverity((Severity)newValue); |
| return; |
| case CheckCatalogPackage.CONSTRAINT__MESSAGE: |
| setMessage((String)newValue); |
| return; |
| case CheckCatalogPackage.CONSTRAINT__CATEGORIES: |
| getCategories().clear(); |
| getCategories().addAll((Collection<? extends Category>)newValue); |
| return; |
| case CheckCatalogPackage.CONSTRAINT__COMMENT: |
| setComment((String)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case CheckCatalogPackage.CONSTRAINT__SEVERITY: |
| setSeverity(SEVERITY_EDEFAULT); |
| return; |
| case CheckCatalogPackage.CONSTRAINT__MESSAGE: |
| setMessage(MESSAGE_EDEFAULT); |
| return; |
| case CheckCatalogPackage.CONSTRAINT__CATEGORIES: |
| getCategories().clear(); |
| return; |
| case CheckCatalogPackage.CONSTRAINT__COMMENT: |
| setComment(COMMENT_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case CheckCatalogPackage.CONSTRAINT__SEVERITY: |
| return severity != SEVERITY_EDEFAULT; |
| case CheckCatalogPackage.CONSTRAINT__MESSAGE: |
| return MESSAGE_EDEFAULT == null ? message != null : !MESSAGE_EDEFAULT.equals(message); |
| case CheckCatalogPackage.CONSTRAINT__CATEGORIES: |
| return categories != null && !categories.isEmpty(); |
| case CheckCatalogPackage.CONSTRAINT__COMMENT: |
| return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (severity: "); |
| result.append(severity); |
| result.append(", message: "); |
| result.append(message); |
| result.append(", comment: "); |
| result.append(comment); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ConstraintImpl |