blob: cd06b36c10dec118617be02a12bca828e7bcbaab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
*
* 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:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.uml.profilefacet.queries.getter;
import java.util.Collection;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDomain;
import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypeFacet;
import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypePropertyElement;
import org.eclipse.papyrus.uml.profilefacet.utils.ArgumentUtils;
import org.eclipse.papyrus.uml.profilefacet.utils.StereotypePropertyUtils;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
public class GetGenericSingleValue<R> implements IJavaModelQueryWithEditingDomain<Element, R> {
/**
*
* @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.facet.infra.query.core.java.ParameterValueList)
*
* @param source
* @param parameterValues
* @return
* @throws ModelQueryExecutionException
*/
public R evaluate(final Element source, final ParameterValueList parameterValues) throws ModelQueryExecutionException {
final StereotypePropertyElement element = (StereotypePropertyElement)parameterValues.getParameterValueByName(ArgumentUtils.EDITED_FEATURE).getValue();
if(element != null) {
final String propertyQN = element.getPropertyQualifiedName();
final String propertyName = NamedElementUtil.getNameFromQualifiedName(propertyQN);
final Stereotype appliedSte = StereotypePropertyUtils.getAppliedStereotype(source, element);
return (R)source.getValue(appliedSte, propertyName);
}
return null;
}
/**
*
* @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQueryWithEditingDomain#evaluate(org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.facet.infra.query.core.java.ParameterValueList, org.eclipse.emf.edit.domain.EditingDomain)
*
* @param context
* @param parameterValues
* @param editingDomain
* @return
* @throws ModelQueryExecutionException
*/
public R evaluate(final Element context, final ParameterValueList parameterValues, EditingDomain editingDomain) throws ModelQueryExecutionException {
return evaluate(context, parameterValues);
}
}
|