blob: a3755c9300d86da50408e3075bf60570ab48191c [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: InterfaceOperations.java,v 1.9 2006/04/05 19:26:35 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.operations;
import java.util.Iterator;
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.EList;
import org.eclipse.uml2.uml.Feature;
import org.eclipse.uml2.uml.Interface;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPlugin;
import org.eclipse.uml2.uml.VisibilityKind;
import org.eclipse.uml2.uml.util.UMLValidator;
/**
* <!-- begin-user-doc -->
* A static utility class that provides operations related to '<em><b>Interface</b></em>' model objects.
* <!-- end-user-doc -->
*
* <p>
* The following operations are supported:
* <ul>
* <li>{@link org.eclipse.uml2.uml.Interface#validateVisibility(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Validate Visibility</em>}</li>
* <li>{@link org.eclipse.uml2.uml.Interface#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.Interface#createOwnedAttribute(java.lang.String, org.eclipse.uml2.uml.Type, int, int) <em>Create Owned Attribute</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class InterfaceOperations
extends ClassifierOperations {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected InterfaceOperations() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* <!-- begin-model-doc -->
* The visibility of all features owned by an interface must be public.
* self.feature->forAll(f | f.visibility = #public)
* <!-- end-model-doc -->
* @generated NOT
*/
public static boolean validateVisibility(Interface interface_,
DiagnosticChain diagnostics, Map context) {
for (Iterator features = interface_.getFeatures().iterator(); features
.hasNext();) {
if (((Feature) features.next()).getVisibility() != VisibilityKind.PUBLIC_LITERAL) {
if (diagnostics != null) {
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING,
UMLValidator.DIAGNOSTIC_SOURCE,
UMLValidator.INTERFACE__VISIBILITY, UMLPlugin.INSTANCE
.getString("_UI_Interface_Visibility_diagnostic", //$NON-NLS-1$
getMessageSubstitutions(context, interface_)),
new Object[]{interface_}));
}
return false;
}
}
return true;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public static Operation createOwnedOperation(Interface interface_,
String name, EList parameterNames, EList parameterTypes,
Type returnType) {
return TypeOperations.createOwnedOperation(interface_, name,
parameterNames, parameterTypes, returnType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public static Property createOwnedAttribute(Interface interface_,
String name, Type type, int lower, int upper) {
return TypeOperations.createOwnedAttribute(interface_, name, type,
lower, upper);
}
} // InterfaceOperations