All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.uml2.uml.internal.operations.ClassOperations Maven / Gradle / Ivy

There is a newer version: 5.0.0-v20140602-0749
Show newest version
/*
 * Copyright (c) 2005, 2011 IBM Corporation, CEA, 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
 *   Kenn Hussey - 323181
 *   Kenn Hussey (CEA) - 327039
 *
 * $Id: ClassOperations.java,v 1.22 2010/09/28 21:02:15 khussey Exp $
 */
package org.eclipse.uml2.uml.internal.operations;

import java.util.Map;

import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;

import org.eclipse.uml2.uml.Operation;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.uml2.common.util.UnionEObjectEList;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Extension;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPlugin;

import org.eclipse.uml2.uml.RedefinableElement;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.util.UMLValidator;

/**
 * 
 * A static utility class that provides operations related to 'Class' model objects.
 * 
 *
 * 

* The following operations are supported: *

    *
  • {@link org.eclipse.uml2.uml.Class#validatePassiveClass(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) Validate Passive Class}
  • *
  • {@link org.eclipse.uml2.uml.Class#createOwnedOperation(java.lang.String, org.eclipse.emf.common.util.EList, org.eclipse.emf.common.util.EList, org.eclipse.uml2.uml.Type) Create Owned Operation}
  • *
  • {@link org.eclipse.uml2.uml.Class#isMetaclass() Is Metaclass}
  • *
  • {@link org.eclipse.uml2.uml.Class#getExtensions() Get Extensions}
  • *
  • {@link org.eclipse.uml2.uml.Class#getSuperClasses() Get Super Classes}
  • *
  • {@link org.eclipse.uml2.uml.Class#inherit(org.eclipse.emf.common.util.EList) Inherit}
  • *
*

* * @generated */ public class ClassOperations extends EncapsulatedClassifierOperations { /** * * * @generated */ protected ClassOperations() { super(); } /** * * * * A passive class may not own receptions. * not self.isActive implies self.ownedReception.isEmpty() * @param class_ The receiving 'Class' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * * @generated NOT */ public static boolean validatePassiveClass( org.eclipse.uml2.uml.Class class_, DiagnosticChain diagnostics, Map context) { if (!class_.isActive() && !(class_.getOwnedReceptions().isEmpty())) { if (diagnostics != null) { diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.CLASS__PASSIVE_CLASS, UMLPlugin.INSTANCE .getString("_UI_Class_PassiveClass_diagnostic", //$NON-NLS-1$ getMessageSubstitutions(context, class_)), new Object[]{class_})); } return false; } return true; } /** * * * @generated NOT */ public static EList getExtensions( org.eclipse.uml2.uml.Class class_) { EList extensions = ECollections. emptyEList(); if (class_.isMetaclass()) { extensions = new UniqueEList.FastCompare(); for (EStructuralFeature.Setting nonNavigableInverseReference : getNonNavigableInverseReferences(class_)) { if (nonNavigableInverseReference.getEStructuralFeature() == UMLPackage.Literals.TYPED_ELEMENT__TYPE) { EObject eObject = nonNavigableInverseReference.getEObject(); if (eObject instanceof Property) { Association association = ((Property) eObject) .getAssociation(); if (association instanceof Extension) { extensions.add((Extension) association); } } } } } return new UnionEObjectEList((InternalEObject) class_, UMLPackage.Literals.CLASS__EXTENSION, extensions.size(), extensions.toArray()); } /** * * * * Missing derivation for Class::/superClass : Class * true * @param class_ The receiving 'Class' model object. * * @generated NOT */ public static EList getSuperClasses( org.eclipse.uml2.uml.Class class_) { return class_.getSuperClasses(); } /** * * * * Creates an operation with the specified name, parameter names, parameter types, and return type (or null) as an owned operation of this class. * @param class_ The receiving 'Class' model object. * @param name The name for the new operation, or null. * @param parameterNames The parameter names for the new operation, or null. * @param parameterTypes The parameter types for the new operation, or null. * @param returnType The return type for the new operation, or null. * * @generated NOT */ public static Operation createOwnedOperation( org.eclipse.uml2.uml.Class class_, String name, EList parameterNames, EList parameterTypes, Type returnType) { return TypeOperations.createOwnedOperation(class_, name, parameterNames, parameterTypes, returnType); } /** * * * * Determines whether this class is a metaclass. * @param class_ The receiving 'Class' model object. * * @generated NOT */ public static boolean isMetaclass(org.eclipse.uml2.uml.Class class_) { return class_.getAppliedStereotype("StandardProfileL2" //$NON-NLS-1$ + NamedElement.SEPARATOR + "Metaclass") != null; //$NON-NLS-1$ } /** * * * * The inherit operation is overridden to exclude redefined properties. * result = inhs->excluding(inh | ownedMember->select(oclIsKindOf(RedefinableElement))->select(redefinedElement->includes(inh))) * @param class_ The receiving 'Class' model object. * * @generated NOT */ public static EList inherit( org.eclipse.uml2.uml.Class class_, EList inhs) { EList inherit = new UniqueEList.FastCompare(); EList redefinedElements = new UniqueEList.FastCompare(); for (NamedElement ownedMember : class_.getOwnedMembers()) { if (ownedMember instanceof RedefinableElement) { redefinedElements.addAll(((RedefinableElement) ownedMember) .getRedefinedElements()); } } for (NamedElement inh : inhs) { if (!redefinedElements.contains(inh)) { inherit.add(inh); } } return ECollections.unmodifiableEList(inherit); } } // ClassOperations




© 2015 - 2024 Weber Informatics LLC | Privacy Policy