blob: 900f94da7fb21a6890bb801df51915e4809b9b42 (
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
|
package org.eclipse.papyrus.core.queries.test.modisco.queries;
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.ParameterValueList;
import org.eclipse.uml2.uml.LiteralString;
import org.eclipse.uml2.uml.NamedElement;
/** test - test if the name of the element is equal to the specified name */
public class CopyOfIsNamed implements IJavaModelQuery<NamedElement, Boolean> {
/**
* {@inheritDoc}
*/
public Boolean evaluate(final NamedElement context, final ParameterValueList parameterValues)
throws ModelQueryExecutionException {
// retrieve the parameter name
Object value = parameterValues.getParameterValueByName("name");
if(value == null) {
throw new ModelQueryExecutionException("The parameter name has no values");
}
if(!(value instanceof LiteralString)) {
throw new ModelQueryExecutionException("The parameter name does not have a String value");
}
if(context == null) {
throw new ModelQueryExecutionException("The context is null, should be a NamedElement");
}
return ((LiteralString)value).stringValue().equalsIgnoreCase(context.getName());
}
}
|