本文整理了Java中org.eclipse.uml2.uml.Operation
类的一些代码示例,展示了Operation
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Operation
类的具体详情如下:
包路径:org.eclipse.uml2.uml.Operation
类名称:Operation
[英]A representation of the model object 'Operation'. An operation is a behavioral feature of a classifier that specifies the name, type, parameters, and constraints for invoking an associated behavior. An operation may invoke both the execution of method behaviors as well as other behavioral responses. Operation specializes TemplateableElement in order to support specification of template operations and bound operations. Operation specializes ParameterableElement to specify that an operation can be exposed as a formal template parameter, and provided as an actual parameter in a binding of a template.
The following features are supported:
代码示例来源:origin: org.andromda.bootstrap.metafacades/andromda-metafacades-emf-uml22
public int compare(final Operation operation1, final Operation operation2)
{
int rtn = operation1.getName().compareTo(operation2.getName());
if (rtn == 0)
{
rtn = operation1.getOwnedParameters().size() - operation1.getOwnedParameters().size();
if (rtn == 0)
{
int index = 0;
for (Parameter parameter : operation1.getOwnedParameters())
{
rtn = parameter.getName().compareTo(operation2.getOwnedParameters().get(index).getName());
if (rtn != 0)
{
break;
}
index++;
}
}
}
return rtn;
}
}
代码示例来源:origin: org.andromda.metafacades/andromda-metafacades-emf-uml22
/**
* @see org.andromda.metafacades.uml.OperationFacade#getReturnType()
*/
@Override
protected Type handleGetReturnType()
{
return this.metaObject.getType();
}
代码示例来源:origin: org.andromda.metafacades/andromda-metafacades-emf-uml22
/**
* @see org.andromda.metafacades.uml.OperationFacade#getParameters()
*/
@Override
protected Collection<Parameter> handleGetParameters()
{
final Collection<Parameter> params = new ArrayList<Parameter>(this.metaObject.getOwnedParameters());
params.add(this.metaObject.getReturnResult());
CollectionUtils.filter(
params,
new Predicate()
{
public boolean evaluate(final Object object)
{
return object != null && !((Parameter)object).isException();
}
});
return params;
}
代码示例来源:origin: org.andromda.bootstrap.metafacades/andromda-metafacades-emf-uml22
/**
* @see org.andromda.metafacades.uml.OperationFacade#getOwner()
*/
@Override
protected Object handleGetOwner()
{
Object obj = null;
// Fix from UML2, no longer calls getOwner to get the owning Class
if (this.metaObject.getInterface()!=null)
{
obj = this.metaObject.getInterface();
}
else if (this.metaObject.getDatatype()!=null)
{
obj = this.metaObject.getDatatype();
}
else
{
obj = this.metaObject.getClass_();
}
return obj;
}
代码示例来源:origin: org.eclipse.uml2/org.eclipse.uml2.uml
@Override
public Object caseOperation(Operation operation) {
Namespace namespace = operation.getNamespace();
.getEGenericExceptions();
for (Type raisedException : operation.getRaisedExceptions()) {
EGenericType eGenericType = getEGenericType(raisedException);
.setEGenericType(getEGenericType(operation.getType()));
int upper = operation.getUpper();
int lower = operation.getLower();
eOperation.setOrdered(operation.isOrdered());
eOperation.setUnique(operation.isUnique());
代码示例来源:origin: org.umlg/java-generation-util
@Override
public EList<Parameter> getOwnedParameters() {
return this.operation.getOwnedParameters();
}
代码示例来源:origin: org.umlg/java-generation
@Override
public void visitBefore(Operation oper) {
Element operOwner = oper.getOwner();
if (oper.getBodyCondition() != null && !oper.isQuery()) {
throw new IllegalStateException(String.format("Operation %s on %s has a bodyCondition but is not a query.",
new Object[] { oper.getName(), ((NamedElement) operOwner).getName() }));
}
OJAnnotatedClass ojClass;
if (operOwner instanceof Interface) {
ojClass = findOJClass((Interface) operOwner);
addOperSignature(ojClass, oper);
} else if ((operOwner instanceof org.eclipse.uml2.uml.Class) || (operOwner instanceof Enumeration)) {
ojClass = findOJClass((org.eclipse.uml2.uml.Classifier) operOwner);
OJAnnotatedOperation ojOper = addOperSignature(ojClass, oper);
if (oper.isQuery()) {
addQueryBody(ojClass, ojOper, oper);
}
} else {
throw new IllegalStateException("Operations are only supported on Interfaces and Classes, not on " + operOwner.toString());
}
}
代码示例来源:origin: org.umlg/java-generation-util
@Override
public String getName() {
return this.operation.getName();
}
代码示例来源:origin: org.umlg/java-generation-util
public static String asOclSignature(Operation oper) {
StringBuilder sb = new StringBuilder();
if (oper.getClass_() != null) {
sb.append(oper.getClass_().getName());
} else if (oper.getDatatype() != null) {
sb.append(oper.getDatatype().getName());
} else {
throw new IllegalStateException("Operation only supported on Class and Datatype");
sb.append(oper.getName());
sb.append("(");
List<Parameter> parametersExceptReturn = getParametersExceptReturn(oper);
Parameter returnResult = oper.getReturnResult();
if (returnResult!=null) {
sb.append(" : ");
代码示例来源:origin: org.eclipse.uml2/org.eclipse.uml2.uml
getOwnedOperations(classifier).add(operation);
operation.setName(eOperation.getName());
operation.createReturnResult(null, getType(eOperation,
eGenericType));
EList<Type> raisedExceptions = operation.getRaisedExceptions();
operation.setVisibility(VisibilityKind.PUBLIC_LITERAL);
&& upperBound != operation.getUpper()) {
operation.setUpper(upperBound);
if (lowerBound != operation.getLower()) {
operation.setLower(lowerBound);
operation.setIsOrdered(eOperation.isOrdered());
operation.setIsUnique(eOperation.isUnique());
代码示例来源:origin: crowdcode-de/KissMDA
when(iteratorOperation.hasNext()).thenReturn(true, false);
when(iteratorOperation.next()).thenReturn(operation);
when(operation.getName()).thenReturn("calculateMe");
when(operation.getType()).thenReturn(operationType);
when(operation.getRaisedExceptions()).thenReturn(raisedExceptions);
when(raisedExceptions.iterator()).thenReturn(iteratorException);
when(iteratorException.hasNext()).thenReturn(true, false);
代码示例来源:origin: org.andromda.metafacades/andromda-metafacades-emf-uml22
fullName = operation.getName() + '(' + fullName + ')';
final Object classifier = operation.getOwner();
if (classifier != null && classifier instanceof NamedElement)
代码示例来源:origin: org.umlg/java-generation-util
@Override
public Parameter getReturnResult() {
return this.operation.getReturnResult();
}
代码示例来源:origin: org.eclipse.uml2/org.eclipse.uml2.uml
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public static void setIsOrdered(Operation operation, boolean newIsOrdered) {
Parameter returnResult = operation.getReturnResult();
if (returnResult == null) {
returnResult = operation.createOwnedParameter(null, null);
returnResult.setDirection(ParameterDirectionKind.RETURN_LITERAL);
}
returnResult.setIsOrdered(newIsOrdered);
}
代码示例来源:origin: org.eclipse.ocl/uml
public Operation defineOperation(Classifier owner, String name,
Classifier type, List<Variable<Classifier, Parameter>> params,
Constraint constraint) {
resetTypeCaches();
Operation result = UMLFactory.eINSTANCE.createOperation();
result.addKeyword(UMLReflection.OCL_HELPER);
result.setName(name);
result.setType(type == null ? getOCLStandardLibrary().getOclVoid()
: type);
result.setIsQuery(true); // OCL can only define queries
for (Variable<Classifier, Parameter> next : params) {
Parameter param = UMLFactory.eINSTANCE.createParameter();
param.setName(next.getName());
param.setType(next.getType() == null ? getOCLStandardLibrary()
.getOclVoid()
: next.getType());
param.setDirection(ParameterDirectionKind.IN_LITERAL);
param.setEffect(ParameterEffectKind.READ_LITERAL);
result.getOwnedParameters().add(param);
}
annotate(result, constraint);
addHelperOperation(owner, result);
return result;
}
代码示例来源:origin: org.eclipse.ocl/uml
result = operation.getName();
if (stereo != null) {
String alias = (String) operation.getValue(stereo,
UMLUtil.TAG_DEFINITION__OPERATION_NAME);
if ((alias != null) && (alias.length() > 0)) {
代码示例来源:origin: crowdcode-de/KissMDA
private void generateMethodReturnType(AST ast, TypeDeclaration td,
Operation operation, MethodDeclaration md) {
Type type = operation.getType();
String umlTypeName = type.getName();
String umlQualifiedTypeName = type.getQualifiedName();
logger.log(Level.FINE, "UmlQualifiedTypeName: " + umlQualifiedTypeName
+ " - " + "umlTypeName: " + umlTypeName);
if (operation.getUpper() >= 0) {
// Upper Cardinality 0..1
// Only for parameterized type
if (dataTypeUtils.isParameterizedType(umlTypeName)) {
Map<String, String> types = umlHelper
.checkParameterizedTypeForTemplateParameterSubstitution(type);
umlTypeName = types.get("umlTypeName");
umlQualifiedTypeName = types.get("umlQualifiedTypeName");
}
jdtHelper.createReturnType(ast, td, md, umlTypeName,
umlQualifiedTypeName, sourceDirectoryPackageName);
} else {
// Upper Cardinality 0..*
generateAssociationEndUpperCardinalityMultiples(ast, td, operation,
md, umlTypeName, umlQualifiedTypeName);
}
}
代码示例来源:origin: crowdcode-de/KissMDA
String umlQualifiedTypeName) {
if (operation.isOrdered() && !operation.isUnique()) {
} else if (operation.isUnique() && !operation.isOrdered()) {
} else if (operation.isUnique() && operation.isOrdered()) {
代码示例来源:origin: org.eclipse.uml2/org.eclipse.uml2.uml
EList<Parameter> ownedParameters = operation.getOwnedParameters();
int ownedParametersSize = ownedParameters.size();
EList<Parameter> opOwnedParameters = op.getOwnedParameters();
EList<Parameter> returnResult = operation.returnResult();
int returnResultSize = returnResult.size();
EList<Parameter> opReturnResult = op.returnResult();
代码示例来源:origin: org.eclipse.uml2/org.eclipse.uml2.uml
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* <!-- begin-model-doc -->
* A bodyCondition can only be specified for a query operation.
* bodyCondition->notEmpty() implies isQuery
* @param operation The receiving '<em><b>Operation</b></em>' model object.
* @param diagnostics The chain of diagnostics to which problems are to be appended.
* @param context The cache of context-specific information.
* <!-- end-model-doc -->
* @generated NOT
*/
public static boolean validateOnlyBodyForQuery(Operation operation,
DiagnosticChain diagnostics, Map<Object, Object> context) {
boolean result = true;
if (operation.getBodyCondition() != null && !operation.isQuery()) {
result = false;
if (diagnostics != null) {
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING,
UMLValidator.DIAGNOSTIC_SOURCE,
UMLValidator.OPERATION__ONLY_BODY_FOR_QUERY,
UMLPlugin.INSTANCE.getString(
"_UI_Operation_OnlyBodyForQuery_diagnostic", //$NON-NLS-1$
getMessageSubstitutions(context, operation)),
new Object[]{operation}));
}
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!