Skip to main content


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 08:15 Go to next message
Andreas Brieg is currently offline Andreas BriegFriend
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 10:33 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
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 11:01 Go to previous message
Andreas Brieg is currently offline Andreas BriegFriend
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: Thu Apr 25 22:53:12 GMT 2024

Powered by FUDForum. Page generated in 0.02967 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top