Over a million developers have joined DZone.

Generating Array Accessors in EMF

DZone's Guide to

Generating Array Accessors in EMF

· Java Zone
Free Resource

Managing a MongoDB deployment? Take a load off and live migrate to MongoDB Atlas, the official automated service, with little to no downtime.

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 :: 


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 !


MongoDB Atlas is the easiest way to run the fastest-growing database for modern applications — no installation, setup, or configuration required. Easily live migrate an existing workload or start with 512MB of storage for free.


Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}