.. ******************************************************************************* * MetaFactory.io R2 * Technical Documentation * * File name : CIX_JCIE_Class.rst * Created by : Marnix Bochove (original text) * Updated by : Niels de Nies * * MetaFactory BV Amsterdam ******************************************************************************* .. include:: /metadata_include.txt .. include:: /inline-images.txt Class ===== is a child element of and defines the generation of a Java Class. .. rubric:: Usage .. code-block:: xml :caption: example :name: class-01 :linenos: :emphasize-lines: 5-27 ... name="" visibility="" abstract="true|false" final="true|false" enum="true|false" code instruction base condition="" condition="" foreach="package|object|attribute" package="" ... .. rubric:: Attributes .. list-table:: **attributes of ** :widths: 20 80 :header-rows: 1 :class: tight-table * - Name - Details * - name - The name of the java class to be generated. * - visibility - Visibility of the class. Possible values are public, protected and private * - abstract - true or false. Indicates whether or not the generated class should be abstract. * - final - true or false. Indicates whether or not the generated class should be final. * - enum - true or false. Indicates whether or not the generated class should be an enum. Default is false. If true, the childelement *enumConstants* must be defined. **Example:** .. code-block:: xml ... name="Color" visibility="public" enum="true" WHITE, BLACK, RED, YELLOW, BLUE ... This code_instruction class creates the java enum: .. code-block:: java public enum Color { WHITE, BLACK, RED, YELLOW, BLUE; } In practice, enum classes (as wel as normal classes) are created from model object elements. By setting metadata for each model object, you can specify whether an enum or normal java class should be generated: .. code-block:: xml name="${code_instruction.property.model.implementation.class}" visibility="public" enum="${model.property.object.enum}" foreach="object" condition="${model.property.object.enum}==true" ${fmsnippet.java.pojo.enum.enum_constants} Model.xml contains an object (RelationType) with metadata enum=true and metadata for enum_constants: .. code-block:: xml ... true Private,Business 1 ... * - code instruction base - |Loupe S| :ref:`Code instruction base `. .. rubric:: Sub elements .. list-table:: **sub elements of ** :widths: 15 70 15 :header-rows: 1 :class: tight-table * - Name - Details - Number * - generic - Makes the class generic (java 1.5 or higher). - 0 or 1 * - apicommentline - Javadoc that is attached to this class. - 0 or more * - devcommentline - Commentary that is attached to this class. - 0 or more * - import - All library elements under import are translated in the class as import statements. - 0 or more * - annotation - Annotation defined for the class. - 0 or more * - implements - The interface that is implemented by this class. - 0 or more * - inherits - The class from which this class is derived. - 0 or more (java supports only 1) * - enum_constants - Enum values (eg. Private, Business) - 0 or 1 * - :ref:`field ` - Those fields contained in this class. The field element defines both the field and possibly also the related getters and setters (dependent on the access attribute (rw|ro|wo). The getter_body and setter_body child element of field can be used for custom code of a getter of setter. - 0 or more * - :ref:`method ` - Methods included in this class. - 0 or more