blob: 28899d89f9a52f32dab9d8a38456149d2497dd05 [file] [log] [blame]
/*
* Copyright (c) 2005, 2006 IBM Corporation 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
*
* $Id: DataTypeOperations.java,v 1.10 2006/03/07 20:25:17 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.operations;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
import java.util.Iterator;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.uml2.uml.DataType;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.RedefinableElement;
/**
* <!-- begin-user-doc -->
* A static utility class that provides operations related to '<em><b>Data Type</b></em>' model objects.
* <!-- end-user-doc -->
*
* <p>
* The following operations are supported:
* <ul>
* <li>{@link org.eclipse.uml2.uml.DataType#createOwnedOperation(java.lang.String, org.eclipse.emf.common.util.EList, org.eclipse.emf.common.util.EList, org.eclipse.uml2.uml.Type) <em>Create Owned Operation</em>}</li>
* <li>{@link org.eclipse.uml2.uml.DataType#createOwnedAttribute(java.lang.String, org.eclipse.uml2.uml.Type, int, int) <em>Create Owned Attribute</em>}</li>
* <li>{@link org.eclipse.uml2.uml.DataType#inherit(org.eclipse.emf.common.util.EList) <em>Inherit</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class DataTypeOperations
extends ClassifierOperations {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected DataTypeOperations() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public static Operation createOwnedOperation(DataType dataType,
String name, EList parameterNames, EList parameterTypes,
Type returnType) {
return TypeOperations.createOwnedOperation(dataType, name,
parameterNames, parameterTypes, returnType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public static Property createOwnedAttribute(DataType dataType, String name,
Type type, int lower, int upper) {
return TypeOperations.createOwnedAttribute(dataType, name, type, lower,
upper);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* <!-- begin-model-doc -->
* The inherit operation is overridden to exclude redefined properties.
* result = inhs->excluding(inh | ownedMember->select(oclIsKindOf(RedefinableElement))->select(redefinedElement->includes(inh)))
* <!-- end-model-doc -->
* @generated NOT
*/
public static EList inherit(DataType dataType, EList inhs) {
EList inherit = new UniqueEList.FastCompare();
EList redefinedElements = new UniqueEList.FastCompare();
for (Iterator ownedMembers = dataType.getOwnedMembers().iterator(); ownedMembers
.hasNext();) {
Object ownedMember = ownedMembers.next();
if (ownedMember instanceof RedefinableElement) {
redefinedElements.addAll(((RedefinableElement) ownedMember)
.getRedefinedElements());
}
}
for (Iterator i = inhs.iterator(); i.hasNext();) {
Object inh = i.next();
if (!redefinedElements.contains(inh)) {
inherit.add(inh);
}
}
return ECollections.unmodifiableEList(inherit);
}
} // DataTypeOperations