Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Generating Array Accessors in EMF

DZone's Guide to

Generating Array Accessors in EMF

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

Have you ever tried to generate References or variable with multiplicity more than 1? Eclipse being an OOPs follower would always generate a List containing a list of References or Datatypes. But if you are an Array Lover, How do you generate an Array Accessor for 0..* References or 0..* Variables.

There is a hidden variable in EMF that lets you customise ur code generator to generate Array Accessors for all list.

Now where do you find this ... 

1. Select the Root Package of your model in your GENMODEL File.

2. Look in the properties and scroll to the MODEL Section.

3. 1st Property would be Array Accessors. It would be initialised to False by default, Change it to True.

Refer to Figure below :: 

[img_assist|nid=5574|title=|desc=|link=popup|align=center|width=418|height=115]

Now you are all set to generate code. All the generated code would result in Array Accessors wherever we would expect a List.

Thats a quicky. Try it out !

 

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}