What is the customization file?

Modelio Java Designer uses a specific XML file to define the mapping of base types, containers and the default creation of accessors.

These packages are found in the "javaCustomizationFile" XML file, located in the module’s installation directory (< Project_Path >/mda/JavaDesigner/res/custom/).

Mapping model types

You can modify basic type mapping in order to generate your own custom type. The following is an example of type definition from the customization file:

<ModelType name="date">
  <JavaType name="Date">
     <import name="java.util.Date"/>
     <wrapper name="Date"/>
  </JavaType>
 </ModelType>
  • ModelType: the base type in Modelio.

  • JavaType: the corresponding java primitive type or class.

  • Import: the import line to add at generation, if necessary.

  • Wrapper: the java primitive type or class to use if the "wrapper" property is set on the model.

Accessor name generation

The second part of the customization file contains the definition for accessor default patterns.

Elements are defined with several cardinalities, according to multiplicities:

Multiplicity Cardinality

0..1

OptionalSimple.

1..1

MandatorySimple.

0..*

OptionalMultiple.

n..*

MandatoryMultiple.

n..m

Finite.

Each definition corresponds to a specific metaclass, for example:

 <Attribute card="OptionalSimple">
   <getter>
      <defaultPattern>get$Name</defaultPattern>
      <variants>
         <pattern type="boolean">is$Name</pattern>
      </variants>
   </getter>
   <setter>
      <defaultPattern>set$Name</defaultPattern>
   </setter>
 </Attribute>

This definition contains three parts:

  • The default name pattern for getters generated on an attribute is "get$Name", where $Name is replaced by the name of the attribute.

  • If the attribute has a boolean type, the name of the getter is "is$Name" instead of "get$Name".

  • The default name pattern for setters generated on an attribute is "set$Name".

Container generation

In the same part of the customization file, default container can also be specified, for multiple cardinalities. These containers are automatically generated if no container is defined on an element, such as an Attribute, an AssociationEnd or a Parameter. For example:

  <AssociationEnd card="MandatoryMultiple">
  <defaultInterfaceContainer name="List">
  <import name="java.util.List"/>
  </defaultInterfaceContainer>
  <defaultImplementationContainer name="ArrayList">
  <import name="java.util.ArrayList"/>
  </defaultImplementationContainer>
...

This definition contains two parts:

  • The default interface container for an AssociationEnd with a n..* multiplicity is List, with a specific import.

  • The default implementation container for an AssociationEnd with a n..* multiplicity is ArrayList, with a specific import.

Note: You can use "Array" if you do not want specific collections to be generated.