org.eclipse.ocl.expressions.impl.CollectionLiteralExpImpl Maven / Gradle / Ivy
/**
*
*
* Copyright (c) 2006, 2009 IBM Corporation, Zeligsoft Inc., 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 - Initial API and implementation
* Zeligsoft - Bug 207365
*
*
*
* $Id: CollectionLiteralExpImpl.java,v 1.9 2009/06/25 19:23:52 ewillink Exp $
*/
package org.eclipse.ocl.expressions.impl;
import java.util.Collection;
import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.DiagnosticChain;
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.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.ocl.expressions.CollectionKind;
import org.eclipse.ocl.expressions.CollectionLiteralExp;
import org.eclipse.ocl.expressions.CollectionLiteralPart;
import org.eclipse.ocl.expressions.CollectionRange;
import org.eclipse.ocl.expressions.ExpressionsPackage;
import org.eclipse.ocl.expressions.operations.CollectionLiteralExpOperations;
import org.eclipse.ocl.utilities.Visitor;
/**
*
* An implementation of the model object 'Collection Literal Exp'.
*
*
* The following features are implemented:
*
* - {@link org.eclipse.ocl.expressions.impl.CollectionLiteralExpImpl#getKind Kind}
* - {@link org.eclipse.ocl.expressions.impl.CollectionLiteralExpImpl#getPart Part}
* - {@link org.eclipse.ocl.expressions.impl.CollectionLiteralExpImpl#isSimpleRange Simple Range}
*
*
*
* @generated
*/
public class CollectionLiteralExpImpl
extends LiteralExpImpl
implements CollectionLiteralExp {
/**
* The default value of the '{@link #getKind() Kind}' attribute.
*
*
* @see #getKind()
* @generated
* @ordered
*/
protected static final CollectionKind KIND_EDEFAULT = CollectionKind.SET_LITERAL;
/**
* The cached value of the '{@link #getKind() Kind}' attribute.
*
*
* @see #getKind()
* @generated
* @ordered
*/
protected CollectionKind kind = KIND_EDEFAULT;
/**
* The cached value of the '{@link #getPart() Part}' containment reference list.
*
*
* @see #getPart()
* @generated
* @ordered
*/
protected EList> part;
/**
* The default value of the '{@link #isSimpleRange() Simple Range}' attribute.
*
*
* @see #isSimpleRange()
* @generated
* @ordered
*/
protected static final boolean SIMPLE_RANGE_EDEFAULT = false;
/**
*
*
* @generated
*/
protected CollectionLiteralExpImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExpressionsPackage.Literals.COLLECTION_LITERAL_EXP;
}
/**
*
*
* @generated
*/
public CollectionKind getKind() {
return kind;
}
/**
*
*
* @generated
*/
public void setKind(CollectionKind newKind) {
CollectionKind oldKind = kind;
kind = newKind == null
? KIND_EDEFAULT
: newKind;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
ExpressionsPackage.COLLECTION_LITERAL_EXP__KIND, oldKind, kind));
}
/**
*
*
* @generated
*/
public EList> getPart() {
if (part == null) {
part = new EObjectContainmentEList>(
CollectionLiteralPart.class, this,
ExpressionsPackage.COLLECTION_LITERAL_EXP__PART);
}
return part;
}
/**
*
*
* @generated NOT
*/
public boolean isSimpleRange() {
EList> partsList = getPart();
int size = partsList.size();
if (size == 1) {
CollectionLiteralPart part = partsList.get(0);
return part instanceof CollectionRange>;
}
return false;
}
/**
*
*
* @generated
*/
public boolean checkNoCollectionInstances(DiagnosticChain diagnostics,
Map