Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » How to compare model attribute that contains an enum with an enum constant?
How to compare model attribute that contains an enum with an enum constant? [message #983886] Wed, 14 November 2012 03:15 Go to next message
Andreas Brieg is currently offline Andreas Brieg
Messages: 48
Registered: November 2012
Member
I want to create a transformation on the MoDisco Java model, but I have problems when it comes to comparing an attribute value to a enum constant. The relevant part of the transformation at the moment looks like this:

-- @atlcompiler atl2010
-- @nsURI Java=http://www.eclipse.org/MoDisco/Java/0.2.incubation/java

module RefactorBeanValidationForParameterChecking;
create outputJava: Java refining javaInput: Java;

helper context Java!InfixExpression def: isEqualsComparison(): Boolean =
	self.operator.toString() = '==';

According to the ATL user guide I should be able to use
self.operator = #EQUALS
instead of the toString() workaround. However this isn't working. Am I missing something?
Re: How to compare model attribute that contains an enum with an enum constant? [message #984015 is a reply to message #983886] Wed, 14 November 2012 05:33 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 603
Registered: July 2009
Senior Member
Hello,

EQUALS is the value of the "name" attribute of the EEnumLiteral you are handling.
The value of its "literal" attribute is "==" (cf. the MoDisco Java metamodel registered in the EMF registry, you can open it with the MoDisco Model Browser for instance).
So, is the following line working?
self.operator = #"=="
The "" are to escape the = symbol which is part of the ATL language.

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: How to compare model attribute that contains an enum with an enum constant? [message #984045 is a reply to message #984015] Wed, 14 November 2012 06:01 Go to previous message
Andreas Brieg is currently offline Andreas Brieg
Messages: 48
Registered: November 2012
Member
Thanks very much, that works.

Maybe it would be good to mention the escaping in the user guide and also that the value after # refers to the literal value of the enum and not to the name.
Previous Topic:Why does a statement that was removed from it's block still appear in the serialized model?
Next Topic:Is there a way to handle 'The object is not contained in a resource.' nicely from within ATL?
Goto Forum:
  


Current Time: Sat Aug 30 16:33:10 EDT 2014

Powered by FUDForum. Page generated in 0.04763 seconds