From 3c906b475c843068c34c81d70013d18a018d2797 Mon Sep 17 00:00:00 2001 From: Hendrik7889 <44064629+Hendrik7889@users.noreply.github.com> Date: Fri, 29 May 2026 12:55:41 +0200 Subject: [PATCH 01/14] Create GettingStarted.md --- doc/GettingStarted.md | 467 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 467 insertions(+) create mode 100644 doc/GettingStarted.md diff --git a/doc/GettingStarted.md b/doc/GettingStarted.md new file mode 100644 index 000000000..562cfd5be --- /dev/null +++ b/doc/GettingStarted.md @@ -0,0 +1,467 @@ +span + +This page is under construction. + +# Getting Started with the CD4Code Generator + +This page describes the technical installation and usage of the CD4Code Generator for +language developers. This page inspects a simple example class diagram and the +Java classes and other artifacts that are generated from the decorating CD generator. +After installing the CD4Code Generator, as described on this page, it can be used to +automatically generate Java code with additional functionality as described in the +subsequent chapters. + +The decorating CD generator is available as a command line interface (CLI) tool, as a library, and +can easily be used with Gradle. The Gradle integration enables developers to easily employ +the generator in commonly used integrated developer environments (IDEs), such as +Eclipse and IntelliJ IDEA. This page contains information about an example +class digram and the generated files and depending on the selected decorators. +(It also shortly explains some key features of the generator.) + +(Detailed information about all configuration options that can be used in the Cd4Code +Generator can be found in the [Configuration](Configuration.md) page.) + +## Prerequisites: Installing the Java Development Kit (JDK) + +We start with the JDK: Please perform the following steps to install the +Java Development Kit (JDK) and validate that the installation was successful: + +- Install a JDK with at least version 21 provided by Oracle or OpenJDK. +- Make sure the environment variable `JAVA_HOME` points to the installed JDK, and + *not* to the JRE, e.g., the following would be good: + - `/user/lib/jvm/java-21-openjdk` on UNIX or + - `C:\Program Files\Java\jdk-21.*` on Windows. + You will need this in order to run the Java compiler for compiling + the generated Java source files. +- Also make sure that the system variable is set such that the Java + compiler can be used from any directory. JDK installations on UNIX + systems do this automatically. On Windows systems, the `bin` + directory of the JDK installation needs to be appended to the `PATH` + variable, e.g. `%PATH%;%JAVA_HOME%`. +- Test whether the setup was successful. Open a command line shell in + any directory. Execute the command `javac -version`. If this command + is recognized and the shell displays the version of the installed + JDK (e.g., `javac 21.0.10`), then the setup was successful. +- *(Optional)* Install [Gradle](https://gradle.org/install/) version 8.14.4. + +Now we have the prerequisites to run the CD4Code generator from the command line (CLI) +or alternatively using Gradle. + +### Installation + +For installing the CD4Code generator for either the CLI or Gradle usage, +select the suitable tab below and perform the following steps: + +=== "CLI" + +A ready to use version of the tool can be downloaded in the form of an +executable JAR file. +You can use [**this download link**][ToolDownload] for downloading the tool. +Alternatively, the `wget` command can be used to download the latest version +into your working directory: +```shell +wget "https://monticore.de/download/MCCD.jar" -O MCCD.jar +``` + +=== "Gradle" +By adding the `de.rwth.se.cdgen` Gradle plugin to your project, +all class diagrams in the _cds_ source-directory-set (e.g., _src/main/cds_, _src/test/cds_) are generated to Java code. + +```groovy +//TODO imports dont work: import java.util.List; is not found and all lists are marked as missing types + +// build.gradle +plugins { + id 'java-library' + id 'de.rwth.se.cdgen' version '7.9.0-SNAPSHOT' +} + +repositories { + maven { url 'https://nexus.se.rwth-aachen.de/content/groups/public' } +} + +// settings.gradle +pluginManagement { + repositories { + maven { + url "https://nexus.se.rwth-aachen.de/content/groups/public" + } + } +} +``` + +For the main source set, all `.cd` files within the `src/main/cds` directory will be processed. + +=== "Library" + +### Inspect the class diagram + +The CD4Code generator helps to generate Java code from class diagrams. It supports easy +integration within gradle projects, but also as a one-shot generation tool. The CD4Code +generator processes class diagrams that are stored in files. The CD4Code generator will +process all `.cd` files in these directories and generate Java code based on the +class diagrams defined in these files. Each CD contains packages, classes, attributes, +methods, and associations. The CD4Code generator will generate Java code based on the +structure of the class diagram and the applied decorators. + +It is a *key feature* of the CD4Code generator that the generated Java code can be +extended with the addition of decorators. These decorators dictate what artifacts +are generated from the class diagram, or which should not be generated at all. + +```cd4code +package corp; +import java.util.Date; + +classdiagram MyCompany { + + enum CorpKind { SOLE_PROPRIETOR, S_CORP, C_CORP, B_CORP, CLOSE_CORP, NON_PROFIT; } + abstract class Entity; + + package people { + class Person extends Entity { + Date birthday; + List nickNames; + -> Address [*] {ordered}; + } + class Address { + String city; + String street; + int number; + } + } + + class Company extends Entity { + CorpKind kind; + } + class Employee extends people.Person { + int salary; + } + class Share { + int value; + } + + association [1..*] Company (employer) <-> Employee [*]; + composition [1] Company <- Share [*]; + association shareholding [1] Entity (shareholder) -- (owns) Share [*]; + +} +``` +
Listing 2.1: The MyCompany class diagram
+ +As usual in model-based software engineering, the core of the file is the diagram definition itself. +It begins with the `classdiagram` keyword, followed by the name of the diagram, +which must match the filename. In our example, the diagram is named `MyCompany` and +its body is enclosed in curly braces `{ }`. + +Class diagrams can have a package declaration and import statements to integrate external types. +If a class diagram defines a package, the package declaration must be the first statement in +the file and takes the form `package` *QualifiedName*, where `package` is a keyword and +*QualifiedName* is an arbitrary namespace (e.g., `corp`). +The optional imports follow the package definition. Every import is of the +form `import` *QualifiedName*. For instance, the `MyCompany` class diagram +uses `import java.util.Date;` to make the standard Java `Date` class available within the model. +The package `corp` also serves as the default namespace for all generated Java classes +unless specified otherwise. + +Inside the class diagram, various object-oriented constructs can be defined, such as enumerations, +classes, and interfaces. The `MyCompany` diagram introduces the enumeration `CorpKind` using +the `enum` keyword, defining several constants like `SOLE_PROPRIETOR` and `NON_PROFIT`. +It also defines several classes, such as `Entity`, `Person`, and `Company`. The `abstract` +keyword can be applied to classes, as seen with `abstract class Entity;`, instructing the +generator that this class serves as a base concept and cannot be instantiated directly. +Furthermore, the `extends` keyword is used to establish inheritance; for example, +`Company` extends `Entity`, and `Employee` extends `people.Person`. + +To further structure the model, class diagrams can contain nested packages. The `MyCompany` +diagram uses `package people` to group the `Person` and `Address` classes logically. +When referencing classes from other nested packages, their names must be qualified, +which is why `Employee` extends `people.Person`. + +Classes typically contain attributes, which consist of a type and a name. The CD4Code +generator supports standard Java primitive types (like `int number` in `Address`), +imported external types (like `Date birthday`), and predefined generic types +(like `List nickNames`). + +Finally, the class diagram defines how these entities relate to one another using +associations and compositions. These relationships can be defined standalone at +the bottom of the file or inline within a class. For example, `Person` contains +an inline directed association `-> Address [*] {ordered};`. Standalone +relationships use keywords like `association` or `composition`, followed by +cardinalities (e.g., `[1]`, `[1..*]`, `[*]`), the participating classes, +and navigation arrows (`<->` for bidirectional, `<-` for directional, +or `--` for unspecified). Relationships can also be named (e.g., `shareholding`) +and can specify role names in parentheses to clarify the relationship's context, +such as `Company (employer) <-> Employee [*]`. Additional constraints or tags, +such as `{ordered}`, can be appended to instruct the generator to maintain a +specific sorting behavior in the resulting Java collections. + +It is possible to have multiple CD files. The CD4Code generator can process all +files in the specified directories and generate Java code for all class diagrams. + +### Default Configuration: CD2Poj +By default, the [CD2Pojo.ftl](../cdlang/src/main/resources/cd2java/init/CD2Pojo.ftl) template +is used by the generator. +It includes the following transformations: + +* CD4CodeAfterParseTrafo: +* DefaultVisibilityPublicTrafo: absent visibility means *public* + +It includes the following decorators: + +| Decorator | Description | To Enable | To Disable | +|-----------------------------|--------------------------------------------------------------------|--------------------------|-------------------------------------------| +| CopyCreator | Include all elements of the original CD in the output | always | - | +| GetterDecorator | Add Getter Methods | 🟩 `<>` | `<>` | +| SetterDecorator | Add Setter Methods | 🟩 `<>` | `<>` | +| CardinalityDefaultDecorator | Optional and list attributes are initialized with an empty default | 🟩 | `<>` | +| NavigableSetterDecorator | Setters of bidirectional associations are also bidirectional | 🟩 `<>` | `<>` | +| AbstractMethodDecorator | Defined methods are made abstract | 🟩 `<>` | `<>` | +| BuilderDecorator | Add a builder class | 🟨 `<>` | `<>` | +| ObserverDecorator | Turn the class observable | 🟨 `<>` | `<>` | +| VisitorDecorator | Include a visitor | 🟨 `<>` | `<>` or `<>` | + +In the default configuration, +🟩 means the decorator is applied unless disabled. +🟨 means the decorator is not applied unless enabled. + +This means by default that the CD4Code generator will generate getters and setters for all attributes. +Furthermore, it will initialize the cardinality of all optional attributes with an empty default value +and the class `People` is initated with an empty list. Finally, the bidirectional associations between +`Company` and `Employee` will be navigable in both directions, meaning that the generated setter methods +will also set the opposite side of the association by default. + +### Configuring the CD4Code Generator + +While the default `CD2Pojo` configuration is a great starting point, manually adding stereotypes +(like `<>` or `<>`) directly to every element in a `.cd` file can become +tedious and clutter the model. To solve this, the CD4Code Generator allows you to configure +decorators externally. + +Configuration can be applied at two different levels: + +1. **Element-Level Configuration (Tagging):** You can target specific elements inside your class diagram + (such as a specific class, enum, or attribute) to explicitly enable or disable a decorator. + This uses a targeting syntax of `.:`. For example, targeting + `MyCompany.Address:noSetter` will prevent the generator from creating setter methods specifically for + the `Address` class. +2. **Global-Level Configuration (Templates):** If you need to fundamentally change the default behavior or + apply your own custom decorators across the entire build, you can supply a custom configuration template + (e.g., a custom `.ftl` file) to replace the default `CD2Pojo` template. + +### Applying Configurations + +Depending on how you are running the CD4Code Generator, you can pass these configurations via the command line, +your Gradle build script, or directly through the Java API. Select your environment below: + +=== "CLI" + +When running the CD4Code generator from the command line, you can pass element-level tags using the `-cliconfig` +parameter. Multiple configurations can be applied by repeating the argument. + +For example, to disable getters and setters specifically for the `Address` class inside the `MyCompany` +diagram, use the following command: + +```shell +java -jar MCCD.jar -i src/MyCompany.cd -cliconfig "MyCompany.Address:noGetter" -cliconfig "MyCompany.Address:noSetter" +``` + +To apply a global configuration template, use the `-ct` (config template) argument to specify the +template name, and `-fp` (file path) to specify the directory where the custom `.ftl` file is located: + +```shell +java -jar MCCD.jar -i src/MyCompany.cd -ct CD2OwnDecorator -fp src/main/configTemplate +``` + +=== "Gradle" + +When using Gradle, element-level configurations can be added directly to the `options` list of the +`generateClassDiagrams` task. + +```groovy +// build.gradle +tasks.named("generateClassDiagrams") { + // Element-level configuration targeting the Address class + options.add("MyCompany.Address:noGetter") + options.add("MyCompany.Address:noSetter") + + // Global-level configuration: Change the config template used by the generator + // getConfigTemplate().set("CD2OwnDecorator") + + // Additional optional configurations: + // getClass2MC().set(true) + // getCoCos().set(false) // (Not encouraged!) + // getOriginalSymbolOutput().set(...) + // getDecoratedSymbolOutput().set(...) + // getOutputDir().set(...) +} + +repositories { + maven { url '[https://nexus.se.rwth-aachen.de/content/groups/public](https://nexus.se.rwth-aachen.de/content/groups/public)' } + mavenCentral() +} +``` + +=== "Library" +//TODO + +## Running the CD4Code Generator +The execution of the CD4Code Generator follows a structured pipeline. +First parsing and validating the model, then managing its symbols, and finally transforming the diagram +into executable Java source code. + +### 1. Loading, CoCo-Checking, and Symbol Table Creation +The first phase of execution focuses on frontend processing. The generator loads the .cd file, parses its +contents, creates an internal symbol table to resolve types, and runs Context Conditions (CoCos) to +ensure the diagram adheres to all semantic rules of the language. + +=== "CLI" + +To parse and validate a class diagram model without generating any code artifacts, pass the input file +using the `-i` flag to specify the input file path. By default, basic validation occurs, but you can +explicitly enforce full CoCo checks or enable Java type resolution. + +```shell +# Basic parse, symbol table creation, and check +java -jar MCCD.jar -i src/MyCompany.cd + +# Explicitly check all CD4C Context Conditions (CoCos) +java -jar MCCD.jar -i src/MyCompany.cd --checkcocos + +# Enable resolution of standard Java classes (e.g., java.util.List) within the model +java -jar MCCD.jar -i src/MyCompany.cd --class2mc +``` + +=== "Gradle" +In a standard Gradle setup, the plugin automatically configures these phases as part of its default task +execution pipeline. However, you can control CoCo behavior and type resolution directly within the task +configuration block. +```groovy +// build.gradle +tasks.named("generateClassDiagrams") { + // Enables resolving standard Java classes used inside the CD diagram + getClass2MC().set(true) + + // Controls whether CoCo checks are executed (enabled by default) + getCoCos().set(true) +} +``` + +### 2. Storing and Exporting Symbols +In a large-scale project, comprehensibility suffers when a single file contains all artifacts of our class +diagram. To address this issue, the CD4Code Generator can serialize its symbol table into a standalone +symbol file, which can then be exported or loaded as a dependency by other models. + +=== "CLI" +Use the `-s` or `--symboltable` flag to specify where the serialized symbol table file should be saved. +If your diagram depends on external symbols, use the -path flag to point to the directory containing +those symbol files. +```shell +# Export the symbol table to a specific file +java -jar MCCD.jar -i src/MyCompany.cd -s out/symbols/MyCompany.cdsym + +# Load external dependencies/symbols while processing a diagram +java -jar MCCD.jar -i src/MyCompany.cd -path dependencies/symbols/ +``` + +=== "Gradle" +The Gradle plugin manages symbol storage and tracking automatically, storing original and decorated +symbols in separate build directories. You can customize these locations if your build pipeline +requires a non-standard layout. + +```groovy +// build.gradle +tasks.named("generateClassDiagrams") { + // Customize the output directory for the original symbol table + getOriginalSymbolOutput().set(file("build/custom-symbols/original")) + + // Customize the output directory for the decorated symbol table + getDecoratedSymbolOutput().set(file("build/custom-symbols/decorated")) +} +``` + +### 3. Generating Java Code +Once the model is fully validated and its symbols are resolved, the generator can proceed to execute +the decorators and generate the actual Java source files. + +=== "CLI" +To trigger code generation, you must explicitly include the `--gen` flag. You can combine this with the +`-o` flag to specify the target directory for the generated code, and `--fieldfromrole` to control +how associations are translated into actual class fields. +``` +# Generate Java files into a dedicated output directory +java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources + +# Generate code while explicitly mapping navigable association roles to Java fields +java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources --fieldfromrole navigable +``` + +If your class diagram contains associations (e.g., `association [1..*] Company (employer) <-> Employee [*]`), +the basic `--gen` command will not automatically generate the corresponding Java fields to link these objects. +Instead, you must explicitly tell the generator to map these association roles to fields using the +`--fieldfromrole` flag. + +In our example, the `Company` class has a role named `employer` in its association with `Employee`. +This means the generator will create an `employer` field inside the generated `Employee` Java class to represent +the relationship. To generate these fields, use the following command: + +```shell +java -jar MCCD.jar -i src/MyCompany.cd -o out --gen --fieldfromrole navigable +``` + + +=== "Gradle" +Code generation is fully integrated into the standard Gradle lifecycle. Executing the `build` task or the +specific `generateClassDiagrams` task automatically processes all source sets and places the output in the +configured directory. + +```groovy +// build.gradle +tasks.named("generateClassDiagrams") { + // Set the target directory for the generated Java files + getOutputDir().set(file("build/generated/sources/cdgen/main/java")) +} +``` + +=== "Gradle" +Just like the CLI, the Gradle plugin does not generate fields for associations by default. You must explicitly configure the task to map these roles to Java fields. + +You can do this by setting the `fieldFromRole` property inside your generation task: + +```groovy +// build.gradle +tasks.named("generateClassDiagrams") { + // Set the target directory for the generated Java files + getOutputDir().set(file("build/generated/sources/cdgen/main/java")) + + // Explicitly map navigable association roles to generated Java fields + getFieldFromRole().set("navigable") +} +``` + +Running the CD4Code generator tooled into a Gradle build is as simple as executing the Gradle build task. + +=== "Library" + +### Inspecting the Generated Code +The generated code should now be located in the specified directory. Let's take a look at the generated code. + +```text +my-project/ +β”œβ”€β”€ src/ +β”‚ └── main/ +β”‚ β”œβ”€β”€ cds/ +β”‚ β”‚ └── MyCompany.cd +β”‚ └── java/ +β”œβ”€β”€ configTemplate/ +β”‚ └── CD2OwnDecorator.ftl +└── build.gradle + README.md +``` + + + + + + + + From 34422acac3c40bca3fc43f4a6cb54f34dcb7f1d8 Mon Sep 17 00:00:00 2001 From: Hendrik7889 <44064629+Hendrik7889@users.noreply.github.com> Date: Mon, 1 Jun 2026 10:54:41 +0200 Subject: [PATCH 02/14] add mkdocs init --- {doc => docs}/Adapter.cd | 0 {doc => docs}/BankingCon.cd | 0 {doc => docs}/BankingRef.cd | 0 {doc => docs}/BuilderRef.cd | 0 {doc => docs}/CDGen.md | 0 {doc => docs}/DataModelCon.cd | 0 {doc => docs}/DigitalTwin1.cd | 0 {doc => docs}/DigitalTwin2.cd | 0 {doc => docs}/DigitalTwin3.cd | 0 {doc => docs}/GettingStarted.md | 363 +++++++++--------- {doc => docs}/GraphAdapter.cd | 0 {doc => docs}/IOAdapter.cd | 0 {doc => docs}/Management.cd | 0 {doc => docs}/MyAddress.cd | 0 {doc => docs}/MyCompany.cd | 0 {doc => docs}/MyEmployees1.cd | 0 {doc => docs}/MyEmployees2.cd | 0 {doc => docs}/MyExample.cd | 0 {doc => docs}/MyLife.cd | 0 {doc => docs}/MyLife.svg | 0 {doc => docs}/MyWorkplace.cd | 0 {doc => docs}/Teaching.cd | 0 {doc => docs}/cwdiff_DT3_DT2_module.als | 0 {doc => docs}/mrg-param.json | 0 .../__pycache__/docsnippet.cpython-312.pyc | Bin 0 -> 10609 bytes docs/overrides/extensions/docsnippet.py | 294 ++++++++++++++ {doc => docs}/owdiff_DT3_DT2_module.als | 0 docs/scripts/preprocessing.sh | 88 +++++ docs/stylesheets/extra.css | 25 ++ mkdocs.yml | 78 ++++ 30 files changed, 657 insertions(+), 191 deletions(-) rename {doc => docs}/Adapter.cd (100%) rename {doc => docs}/BankingCon.cd (100%) rename {doc => docs}/BankingRef.cd (100%) rename {doc => docs}/BuilderRef.cd (100%) rename {doc => docs}/CDGen.md (100%) rename {doc => docs}/DataModelCon.cd (100%) rename {doc => docs}/DigitalTwin1.cd (100%) rename {doc => docs}/DigitalTwin2.cd (100%) rename {doc => docs}/DigitalTwin3.cd (100%) rename {doc => docs}/GettingStarted.md (64%) rename {doc => docs}/GraphAdapter.cd (100%) rename {doc => docs}/IOAdapter.cd (100%) rename {doc => docs}/Management.cd (100%) rename {doc => docs}/MyAddress.cd (100%) rename {doc => docs}/MyCompany.cd (100%) rename {doc => docs}/MyEmployees1.cd (100%) rename {doc => docs}/MyEmployees2.cd (100%) rename {doc => docs}/MyExample.cd (100%) rename {doc => docs}/MyLife.cd (100%) rename {doc => docs}/MyLife.svg (100%) rename {doc => docs}/MyWorkplace.cd (100%) rename {doc => docs}/Teaching.cd (100%) rename {doc => docs}/cwdiff_DT3_DT2_module.als (100%) rename {doc => docs}/mrg-param.json (100%) create mode 100644 docs/overrides/extensions/__pycache__/docsnippet.cpython-312.pyc create mode 100644 docs/overrides/extensions/docsnippet.py rename {doc => docs}/owdiff_DT3_DT2_module.als (100%) create mode 100644 docs/scripts/preprocessing.sh create mode 100644 docs/stylesheets/extra.css create mode 100644 mkdocs.yml diff --git a/doc/Adapter.cd b/docs/Adapter.cd similarity index 100% rename from doc/Adapter.cd rename to docs/Adapter.cd diff --git a/doc/BankingCon.cd b/docs/BankingCon.cd similarity index 100% rename from doc/BankingCon.cd rename to docs/BankingCon.cd diff --git a/doc/BankingRef.cd b/docs/BankingRef.cd similarity index 100% rename from doc/BankingRef.cd rename to docs/BankingRef.cd diff --git a/doc/BuilderRef.cd b/docs/BuilderRef.cd similarity index 100% rename from doc/BuilderRef.cd rename to docs/BuilderRef.cd diff --git a/doc/CDGen.md b/docs/CDGen.md similarity index 100% rename from doc/CDGen.md rename to docs/CDGen.md diff --git a/doc/DataModelCon.cd b/docs/DataModelCon.cd similarity index 100% rename from doc/DataModelCon.cd rename to docs/DataModelCon.cd diff --git a/doc/DigitalTwin1.cd b/docs/DigitalTwin1.cd similarity index 100% rename from doc/DigitalTwin1.cd rename to docs/DigitalTwin1.cd diff --git a/doc/DigitalTwin2.cd b/docs/DigitalTwin2.cd similarity index 100% rename from doc/DigitalTwin2.cd rename to docs/DigitalTwin2.cd diff --git a/doc/DigitalTwin3.cd b/docs/DigitalTwin3.cd similarity index 100% rename from doc/DigitalTwin3.cd rename to docs/DigitalTwin3.cd diff --git a/doc/GettingStarted.md b/docs/GettingStarted.md similarity index 64% rename from doc/GettingStarted.md rename to docs/GettingStarted.md index 562cfd5be..3bf1dbf63 100644 --- a/doc/GettingStarted.md +++ b/docs/GettingStarted.md @@ -1,5 +1,4 @@ -span - + This page is under construction. # Getting Started with the CD4Code Generator @@ -53,48 +52,42 @@ For installing the CD4Code generator for either the CLI or Gradle usage, select the suitable tab below and perform the following steps: === "CLI" - -A ready to use version of the tool can be downloaded in the form of an -executable JAR file. -You can use [**this download link**][ToolDownload] for downloading the tool. -Alternatively, the `wget` command can be used to download the latest version -into your working directory: -```shell -wget "https://monticore.de/download/MCCD.jar" -O MCCD.jar -``` - + A ready to use version of the tool can be downloaded in the form of an + executable JAR file. + You can use [**this download link**][ToolDownload] for downloading the tool. + Alternatively, the `wget` command can be used to download the latest version + into your working directory: + ```shell + wget "https://monticore.de/download/MCCD.jar" -O MCCD.jar + ``` === "Gradle" -By adding the `de.rwth.se.cdgen` Gradle plugin to your project, -all class diagrams in the _cds_ source-directory-set (e.g., _src/main/cds_, _src/test/cds_) are generated to Java code. - -```groovy -//TODO imports dont work: import java.util.List; is not found and all lists are marked as missing types - -// build.gradle -plugins { - id 'java-library' - id 'de.rwth.se.cdgen' version '7.9.0-SNAPSHOT' -} - -repositories { - maven { url 'https://nexus.se.rwth-aachen.de/content/groups/public' } -} - -// settings.gradle -pluginManagement { - repositories { - maven { - url "https://nexus.se.rwth-aachen.de/content/groups/public" + By adding the `de.rwth.se.cdgen` Gradle plugin to your project, + all class diagrams in the _cds_ source-directory-set (e.g., _src/main/cds_, _src/test/cds_) are generated to Java code. + + ```groovy + // build.gradle + plugins { + id 'java-library' + id 'de.rwth.se.cdgen' version '7.9.0-SNAPSHOT' } - } -} -``` - -For the main source set, all `.cd` files within the `src/main/cds` directory will be processed. - -=== "Library" + + repositories { + maven { url 'https://nexus.se.rwth-aachen.de/content/groups/public' } + mavenCentral() + } + + // settings.gradle + pluginManagement { + repositories { + maven { + url "https://nexus.se.rwth-aachen.de/content/groups/public" + } + } + } + ``` + For the main source set, all `.cd` files within the `src/main/cds` directory will be processed. -### Inspect the class diagram +## Inspect the class diagram The CD4Code generator helps to generate Java code from class diagrams. It supports easy integration within gradle projects, but also as a one-shot generation tool. The CD4Code @@ -254,55 +247,45 @@ Depending on how you are running the CD4Code Generator, you can pass these confi your Gradle build script, or directly through the Java API. Select your environment below: === "CLI" - -When running the CD4Code generator from the command line, you can pass element-level tags using the `-cliconfig` -parameter. Multiple configurations can be applied by repeating the argument. - -For example, to disable getters and setters specifically for the `Address` class inside the `MyCompany` -diagram, use the following command: - -```shell -java -jar MCCD.jar -i src/MyCompany.cd -cliconfig "MyCompany.Address:noGetter" -cliconfig "MyCompany.Address:noSetter" -``` - -To apply a global configuration template, use the `-ct` (config template) argument to specify the -template name, and `-fp` (file path) to specify the directory where the custom `.ftl` file is located: - -```shell -java -jar MCCD.jar -i src/MyCompany.cd -ct CD2OwnDecorator -fp src/main/configTemplate -``` + When running the CD4Code generator from the command line, you can pass element-level tags using the `-cliconfig` + parameter. Multiple configurations can be applied by repeating the argument. + + For example, to disable getters and setters specifically for the `Address` class inside the `MyCompany` + diagram, use the following command: + + ```shell + java -jar MCCD.jar -i src/MyCompany.cd -cliconfig "MyCompany.Address:noGetter" -cliconfig "MyCompany.Address:noSetter" + ``` + + To apply a global configuration template, use the `-ct` (config template) argument to specify the + template name, and `-fp` (file path) to specify the directory where the custom `.ftl` file is located: + + ```shell + java -jar MCCD.jar -i src/MyCompany.cd -ct CD2OwnDecorator -fp src/main/configTemplate + ``` === "Gradle" - -When using Gradle, element-level configurations can be added directly to the `options` list of the -`generateClassDiagrams` task. - -```groovy -// build.gradle -tasks.named("generateClassDiagrams") { - // Element-level configuration targeting the Address class - options.add("MyCompany.Address:noGetter") - options.add("MyCompany.Address:noSetter") - - // Global-level configuration: Change the config template used by the generator - // getConfigTemplate().set("CD2OwnDecorator") - - // Additional optional configurations: - // getClass2MC().set(true) - // getCoCos().set(false) // (Not encouraged!) - // getOriginalSymbolOutput().set(...) - // getDecoratedSymbolOutput().set(...) - // getOutputDir().set(...) -} - -repositories { - maven { url '[https://nexus.se.rwth-aachen.de/content/groups/public](https://nexus.se.rwth-aachen.de/content/groups/public)' } - mavenCentral() -} -``` - -=== "Library" -//TODO + When using Gradle, element-level configurations can be added directly to the `options` list of the + `generateClassDiagrams` task. + + ```groovy + // build.gradle + tasks.named("generateClassDiagrams") { + // Element-level configuration targeting the Address class + options.add("MyCompany.Address:noGetter") + options.add("MyCompany.Address:noSetter") + + // Global-level configuration: Change the config template used by the generator + // getConfigTemplate().set("CD2OwnDecorator") + + // Additional optional configurations: + // getClass2MC().set(true) + // getCoCos().set(false) // (Not encouraged!) + // getOriginalSymbolOutput().set(...) + // getDecoratedSymbolOutput().set(...) + // getOutputDir().set(...) + } + ``` ## Running the CD4Code Generator The execution of the CD4Code Generator follows a structured pipeline. @@ -315,36 +298,35 @@ contents, creates an internal symbol table to resolve types, and runs Context Co ensure the diagram adheres to all semantic rules of the language. === "CLI" - -To parse and validate a class diagram model without generating any code artifacts, pass the input file -using the `-i` flag to specify the input file path. By default, basic validation occurs, but you can -explicitly enforce full CoCo checks or enable Java type resolution. - -```shell -# Basic parse, symbol table creation, and check -java -jar MCCD.jar -i src/MyCompany.cd - -# Explicitly check all CD4C Context Conditions (CoCos) -java -jar MCCD.jar -i src/MyCompany.cd --checkcocos - -# Enable resolution of standard Java classes (e.g., java.util.List) within the model -java -jar MCCD.jar -i src/MyCompany.cd --class2mc -``` + To parse and validate a class diagram model without generating any code artifacts, pass the input file + using the `-i` flag to specify the input file path. By default, basic validation occurs, but you can + explicitly enforce full CoCo checks or enable Java type resolution. + + ```shell + # Basic parse, symbol table creation, and check + java -jar MCCD.jar -i src/MyCompany.cd + + # Explicitly check all CD4C Context Conditions (CoCos) + java -jar MCCD.jar -i src/MyCompany.cd --checkcocos + + # Enable resolution of standard Java classes (e.g., java.util.List) within the model + java -jar MCCD.jar -i src/MyCompany.cd --class2mc + ``` === "Gradle" -In a standard Gradle setup, the plugin automatically configures these phases as part of its default task -execution pipeline. However, you can control CoCo behavior and type resolution directly within the task -configuration block. -```groovy -// build.gradle -tasks.named("generateClassDiagrams") { - // Enables resolving standard Java classes used inside the CD diagram - getClass2MC().set(true) - - // Controls whether CoCo checks are executed (enabled by default) - getCoCos().set(true) -} -``` + In a standard Gradle setup, the plugin automatically configures these phases as part of its default task + execution pipeline. However, you can control CoCo behavior and type resolution directly within the task + configuration block. + ```groovy + // build.gradle + tasks.named("generateClassDiagrams") { + // Enables resolving standard Java classes used inside the CD diagram + getClass2MC().set(true) + + // Controls whether CoCo checks are executed (enabled by default) + getCoCos().set(true) + } + ``` ### 2. Storing and Exporting Symbols In a large-scale project, comprehensibility suffers when a single file contains all artifacts of our class @@ -352,91 +334,90 @@ diagram. To address this issue, the CD4Code Generator can serialize its symbol t symbol file, which can then be exported or loaded as a dependency by other models. === "CLI" -Use the `-s` or `--symboltable` flag to specify where the serialized symbol table file should be saved. -If your diagram depends on external symbols, use the -path flag to point to the directory containing -those symbol files. -```shell -# Export the symbol table to a specific file -java -jar MCCD.jar -i src/MyCompany.cd -s out/symbols/MyCompany.cdsym - -# Load external dependencies/symbols while processing a diagram -java -jar MCCD.jar -i src/MyCompany.cd -path dependencies/symbols/ -``` + Use the `-s` or `--symboltable` flag to specify where the serialized symbol table file should be saved. + If your diagram depends on external symbols, use the -path flag to point to the directory containing + those symbol files. + ```shell + # Export the symbol table to a specific file + java -jar MCCD.jar -i src/MyCompany.cd -s out/symbols/MyCompany.cdsym + + # Load external dependencies/symbols while processing a diagram + java -jar MCCD.jar -i src/MyCompany.cd -path dependencies/symbols/ + ``` === "Gradle" -The Gradle plugin manages symbol storage and tracking automatically, storing original and decorated -symbols in separate build directories. You can customize these locations if your build pipeline -requires a non-standard layout. - -```groovy -// build.gradle -tasks.named("generateClassDiagrams") { - // Customize the output directory for the original symbol table - getOriginalSymbolOutput().set(file("build/custom-symbols/original")) - - // Customize the output directory for the decorated symbol table - getDecoratedSymbolOutput().set(file("build/custom-symbols/decorated")) -} -``` + The Gradle plugin manages symbol storage and tracking automatically, storing original and decorated + symbols in separate build directories. You can customize these locations if your build pipeline + requires a non-standard layout. + + ```groovy + // build.gradle + tasks.named("generateClassDiagrams") { + // Customize the output directory for the original symbol table + getOriginalSymbolOutput().set(file("build/custom-symbols/original")) + + // Customize the output directory for the decorated symbol table + getDecoratedSymbolOutput().set(file("build/custom-symbols/decorated")) + } + ``` ### 3. Generating Java Code Once the model is fully validated and its symbols are resolved, the generator can proceed to execute the decorators and generate the actual Java source files. === "CLI" -To trigger code generation, you must explicitly include the `--gen` flag. You can combine this with the -`-o` flag to specify the target directory for the generated code, and `--fieldfromrole` to control -how associations are translated into actual class fields. -``` -# Generate Java files into a dedicated output directory -java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources - -# Generate code while explicitly mapping navigable association roles to Java fields -java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources --fieldfromrole navigable -``` - -If your class diagram contains associations (e.g., `association [1..*] Company (employer) <-> Employee [*]`), -the basic `--gen` command will not automatically generate the corresponding Java fields to link these objects. -Instead, you must explicitly tell the generator to map these association roles to fields using the -`--fieldfromrole` flag. - -In our example, the `Company` class has a role named `employer` in its association with `Employee`. -This means the generator will create an `employer` field inside the generated `Employee` Java class to represent -the relationship. To generate these fields, use the following command: - -```shell -java -jar MCCD.jar -i src/MyCompany.cd -o out --gen --fieldfromrole navigable -``` - - -=== "Gradle" -Code generation is fully integrated into the standard Gradle lifecycle. Executing the `build` task or the -specific `generateClassDiagrams` task automatically processes all source sets and places the output in the -configured directory. - -```groovy -// build.gradle -tasks.named("generateClassDiagrams") { - // Set the target directory for the generated Java files - getOutputDir().set(file("build/generated/sources/cdgen/main/java")) -} -``` + To trigger code generation, you must explicitly include the `--gen` flag. You can combine this with the + `-o` flag to specify the target directory for the generated code, and `--fieldfromrole` to control + how associations are translated into actual class fields. + ``` + # Generate Java files into a dedicated output directory + java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources + + # Generate code while explicitly mapping navigable association roles to Java fields + java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources --fieldfromrole navigable + ``` + + If your class diagram contains associations (e.g., `association [1..*] Company (employer) <-> Employee [*]`), + the basic `--gen` command will not automatically generate the corresponding Java fields to link these objects. + Instead, you must explicitly tell the generator to map these association roles to fields using the + `--fieldfromrole` flag. + + In our example, the `Company` class has a role named `employer` in its association with `Employee`. + This means the generator will create an `employer` field inside the generated `Employee` Java class to represent + the relationship. To generate these fields, use the following command: + + ```shell + java -jar MCCD.jar -i src/MyCompany.cd -o out --gen --fieldfromrole navigable + ``` === "Gradle" -Just like the CLI, the Gradle plugin does not generate fields for associations by default. You must explicitly configure the task to map these roles to Java fields. - -You can do this by setting the `fieldFromRole` property inside your generation task: - -```groovy -// build.gradle -tasks.named("generateClassDiagrams") { - // Set the target directory for the generated Java files - getOutputDir().set(file("build/generated/sources/cdgen/main/java")) - - // Explicitly map navigable association roles to generated Java fields - getFieldFromRole().set("navigable") -} -``` + Code generation is fully integrated into the standard Gradle lifecycle. Executing the `build` task or the + specific `generateClassDiagrams` task automatically processes all source sets and places the output in the + configured directory. + + ```groovy + // build.gradle + tasks.named("generateClassDiagrams") { + // Set the target directory for the generated Java files + getOutputDir().set(file("build/generated/sources/cdgen/main/java")) + } + ``` + + # === "Gradle" + # Just like the CLI, the Gradle plugin does not generate fields for associations by default. You must explicitly configure the task to map these roles to Java fields. + # + # You can do this by setting the `fieldFromRole` property inside your generation task: + # + # ```groovy + # // build.gradle + # tasks.named("generateClassDiagrams") { + # // Set the target directory for the generated Java files + # getOutputDir().set(file("build/generated/sources/cdgen/main/java")) + # + # // Explicitly map navigable association roles to generated Java fields + # getFieldFromRole().set("navigable") + # } + # ``` Running the CD4Code generator tooled into a Gradle build is as simple as executing the Gradle build task. diff --git a/doc/GraphAdapter.cd b/docs/GraphAdapter.cd similarity index 100% rename from doc/GraphAdapter.cd rename to docs/GraphAdapter.cd diff --git a/doc/IOAdapter.cd b/docs/IOAdapter.cd similarity index 100% rename from doc/IOAdapter.cd rename to docs/IOAdapter.cd diff --git a/doc/Management.cd b/docs/Management.cd similarity index 100% rename from doc/Management.cd rename to docs/Management.cd diff --git a/doc/MyAddress.cd b/docs/MyAddress.cd similarity index 100% rename from doc/MyAddress.cd rename to docs/MyAddress.cd diff --git a/doc/MyCompany.cd b/docs/MyCompany.cd similarity index 100% rename from doc/MyCompany.cd rename to docs/MyCompany.cd diff --git a/doc/MyEmployees1.cd b/docs/MyEmployees1.cd similarity index 100% rename from doc/MyEmployees1.cd rename to docs/MyEmployees1.cd diff --git a/doc/MyEmployees2.cd b/docs/MyEmployees2.cd similarity index 100% rename from doc/MyEmployees2.cd rename to docs/MyEmployees2.cd diff --git a/doc/MyExample.cd b/docs/MyExample.cd similarity index 100% rename from doc/MyExample.cd rename to docs/MyExample.cd diff --git a/doc/MyLife.cd b/docs/MyLife.cd similarity index 100% rename from doc/MyLife.cd rename to docs/MyLife.cd diff --git a/doc/MyLife.svg b/docs/MyLife.svg similarity index 100% rename from doc/MyLife.svg rename to docs/MyLife.svg diff --git a/doc/MyWorkplace.cd b/docs/MyWorkplace.cd similarity index 100% rename from doc/MyWorkplace.cd rename to docs/MyWorkplace.cd diff --git a/doc/Teaching.cd b/docs/Teaching.cd similarity index 100% rename from doc/Teaching.cd rename to docs/Teaching.cd diff --git a/doc/cwdiff_DT3_DT2_module.als b/docs/cwdiff_DT3_DT2_module.als similarity index 100% rename from doc/cwdiff_DT3_DT2_module.als rename to docs/cwdiff_DT3_DT2_module.als diff --git a/doc/mrg-param.json b/docs/mrg-param.json similarity index 100% rename from doc/mrg-param.json rename to docs/mrg-param.json diff --git a/docs/overrides/extensions/__pycache__/docsnippet.cpython-312.pyc b/docs/overrides/extensions/__pycache__/docsnippet.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c05cd2c363100713438303df73d78b42c503d94 GIT binary patch literal 10609 zcmb_CZBQFWmNU}m69EDQ`ar<&jch(_{0-O+HU>Mku^k)}8?Yj41W4!u&kV*^Mu~Sf zSHU?~1uDB|QBKZsZPi+dQx$UeW69Q4o%imlmaVJ0o3Y4B%x3Gz?fuF9!f|%@_V()T zUXL^a6A|xTUEB2Z$LrVK@4bHS^=tiOz8-^A)ol0O-HlGCB7MZAe!QcCbDfL8;&b{$SGW#LsfG!E^T zsM&#wS|;e7ob<4aTZThlJX3jE423(G2fKt*7)*qtiEbzyO3^rw9(U|I>j^U6P|&T& zj6ol?F|@p=KZ5KI#^D_1gi<|thB9LheKG#fx3X37x-tC5>I1&2S( z%p6ey<{TUM<;l?NUrtHkltLy6j@?i?h_Lx3&zP5CJv7OVdq|JGvsO`)A<~y5VCZ+K zMMZ!Ti|7n=mIR`H%)=fH1xLMOj97a5Xof^*Y0o4ba(fsiM2q>88)}TGm613IkzhRj zQCbI6h-$Zlg+}{i5bsGy|M|+%j^URX56ui8_XH{0J8^`b8tw_XrvjcJ%MAB<+2d1J zhTYU|SJ36Z!FZWrD&%H{L)Sbs?WH`-aCS@So-_wrCvS)aQV(_7MNd$n>0r2OGk05` z1*k{s>VxbiwpwhOA#Q6@T76P$7qs^1`DJZQs;Kl%)m&AgsAfj}d2wT0y`V@G@0v+N zSp=;msjU{Y)v?C-frTrdX%9RFR6tll)H3+Q$nrkNW-9Rw=B_6#t=b~Ogw!NGLTNp2j9&pmyEJm zsgz}LU1o2?W2X^hu&pAS#nYy+G72H|$L`?Ej27AZ_uPvn!v&rwGI5v#Y}>f>OST zUn1ZXt7rp&xHld~q^nTCQ^?E(ZNlgfuAdsCA8-Y%q+5f!J*byO*WQ-xuiJX1u?;XT+pns>Brr5AH6Mk+BZ zqT$rO{7uNA%4y_LJ=h4ShKQEaQn(fMXx~-d))Uxmk^l-sv=PnQ#x3SorRS&AX z1$1`Ch7(+X$gB9j;dS79V zo#b)4ob3iKUsizfcTRD;0d}Q`IL zPBMo(hTDeQ98E))9V6R^Tbq2YYc4L}-tBONONWP=hFmS-?v_hCS`IizwmXJLI>>MV zYQ8)?BGreR!n&r~;eqXr!^4hn)iYh+9R19xL;{4)^waks`+-6_mm5zlw4y}eGD{<1 zReZT1vO*bAaEe>RHJmQm0#YgC8o+LWFeAZ;fFZr50*eL0E(wZ~lG<08Sr@rQFSsWbQn-Q%GBjkL$_V!hWq&U6DK8o(U* zU2c!l?+s2chz3a2-@KXD2Zd=cX9kE4AIfP}S~K>=nXyx?UH*{Usu&R)ji0;kT_{_`Kd~lCI(b89S{H5PNS3D`!kjwy%StlC%6!D&bw+mmiHv+^^jS2)X~@38#$xlG?Q`3s zu6J8!j&9)I%<&Bjeq8E^(J~X=@%;-I5+z-{p)1Y43=sf122N<^NXCGv=t$l&a(Ea_ zXRc!>>+)QN^Hz~e`UpYc9B~&s+xJ1^Q%X(+Wdh1-j>zTZf@arHD(PTqp`?~dI!+bQ zb2>_M4Wk**=vw%OI0dDf0Q%ED=+R3h1(g@XDMKWW%3pUGZyCRRg}GKCuRaV095i@A zE?WkxE2J=6)=p8_`ka(e#*haPpyLg9!2-d~3%EQf&xgE-Q$k++zAjQgm2d@6Msz9U z3L^TTf-*%4sZtJu)-p~HxtUW#Zs7_cx4y3fp|$mg+a(>|(bhKRWyhzkw7Nrqw$q^? z>pdExJ#8C2!?r8_(3LjIbFD30M%G;LdZtMv!(=E(rrpSzaNSS`s4@@jb@^M;=sI2_ zTZ5tCxOZ&a4}WZAq)Egbk_MDcibEk10hc!@8dwj*_Ij_gQ?!S1=)j$&{I1}bnCGV2 zLE8n{sem6fwle|Hk#36ej*f~NHx=;EV;uAsRE~8uPS(&kH`RXku;zSl1QG zGwKa`S-5jZV0t&zLQlaS10In;=8E0}Vk>G;5&U1VWaDC9OgDy=t*vb$-bN!2E39fo zu<#jY12Aod9taei>zZ)$20|brwE$Mh<=#vW5(q-Kp~>-~uwtYstZ|TC%+%x|5hugy zt~OM3s6-7ACFH;65%aRvfDMVNNf*sBqSEgP!Zt$QprcsQF!T;UNbf`$QZ8bCW;ErT z1j8-nrCB4Hk8H&YJ|x|Xpfz9_d>%I|>Y30K4Q7V%up)t!iD<|W$jQ1Gs9kZnC!B1^ zNryrJf%dr$@hm*TF6yqh7*Bc$O7}FyAg3Hzu8k>U#Uyz4hM;{$c*pJVgUbXixMV3PR$P{n8Hghs%Kk}&aQOnX* z-ga*01@b;%Z4HSiwRoU$I9h+_TuYhG~28 z^Y{}?+j$;eGh!EU7tT|@$FKNSoA)j@JZ^qr{s!MWG;2sz)qSLlpGY=$3(eh+Y7@=9 z$>vi+^QlDBX`!kg`pvdG*XORsR54fVN=%n9Z;K!LXkfwoa5#RNH+ReushZYU<$@-D zV-a6$UaWj{b;-1(Uh?qgFYyCI{E(lo3ILYsGyK`%rPuk9%Y2m+VXd7bR;#L^R9ZI6 z&W=WpMA_(QtS^2telUaR8eh`SgQJI>DhDnJrb8<#Xb(sQh>qWTg|31wQ4Nv@7f8AX zRWzV7CK2;BaL6c^-!CeesVg9h$R~x1FcLHmBVA1C3(%BCVUP?UUPU6-*RV&M4Q^ znC0M%A!RMUXPdY2bzO^`PzME08}=v?t@4(zTo_*F}@l=DI>sO1LqrWba?b zfn&D^ISpOB#awC`j>d0KJQqeuX(H<2r<}$B7unn2<21})a|H93K!JkwUCO2BP(aV= z=?GjQznud9Eg-U#+@e2A!{<{9U6!}NlBLeK!02QOehZ9#BMeAQ9yo>i?5s^GjP1kIJ zH(!RLR8)Zt^O<2zhV0H9_Uc1__&f;UXdZABT{1T%s#x9?1hT#dI?~7)bHbI# zaFHUeh%zCD&;=~IuS!X7lcC^xlou)H3Ucbh;_s-qV#+iDaSmF+6$cC0Mi~!ff*w^E zEP)(!k}={Ki%hhXxa{63)daW~bP3EaUFJ5eNotcZNNXzL@^h{!yFbvte@0-z`YmW$ zDr2Kf&x1%)9i-9VL!QT`l)cvGlI=2imWYW{(gbG$ji9_ufm}6jLIc(7I1Nz;&J-!- zN*NT9LRW=NiOb4)5a$e$GOlbEr~ip71L#eVs0!C!G~auG?<$L~2vXw8;BtuhkOQ?T zePogC*d8om1}kfUlW674AXB?Qrfi(ehwe_B5@pTq(!yDDa>bVGtWh?3ocslz?IAGE z0`a(;|N0KDm*o;yF5^IU3{FkC%z+>w z_e3h8ls*;haw#+8w*SkFa4umk8B@-A(*cz#&h9%buXO#(S=ny6##M4vzy%ZngM^O2 z23|&imzeK})b&gz#aoX((D?%;7)7; zf+}YP{-a1NB!E-p+!5wGnTFVyqmf)GS4ibe;UAUD(LZ=vAT!~3@HHbOm&cKah7eTO zNkMf|-UC=Y)$L2L`W!X{^nmL2_@8b^fTCM_(Zu3MGS|3 zU~%8RuDpm%|yg+ z7tMIcOaPjZ3$4AP+QYbAlW_m*l&+vsU{%cb2GK>*i5|;5^m$PU&!TXClt;y6w=hE0v6J2d5|$Y6*iuXxDO&=kD0p}4Jx zH;Z^jIy%(?b%!FXmBV9U4JtvLOvGvQ2<{2GLzFi-1`#YgU&Qrcg&vA(FXKevT|Im= zOLH`$XIco+C|wjK7QS@M*?sDibD;mk*|W#a52WM5bubxiLo0wtj}+V&ivchL1h*Jb54jVfKw}WyQ86s-orK^Gi-JSb5Y&_Alu`AbICTty zYU3UV-5`1}G&-naNrp_Py$l1JI!4p*^Z>;4ds$KG4MG-hU8m8R6IK4uG(^@6uuUg= z`SpiflxT!!Z22i69pWKE@O(*MMI(S#RC*=a>;PpL7D-I8Ucabv`(1%aU^;p|r(jmU z*Xe6rztcI#1KH97h)_vk z2vH}+9niZl&B7>p3Jui-J=5th1#nOjGf@TMPWJ@uL@=)+7)79+_M-xU=q4)DYeiJ1 zk)aid;8cJCRs&Z=1;dI8V7UgwK#EUD5jju}AY!8s+;9PthNT*8pAE4tznBNX6PFa? z@IXip-t|%BL}DUP#EB+T_}iIk7_>27mb09G;{HB>hU>P7VLU@AxIkk}0|c~vqUY`n&JV_%%N2VdqETA0T3U8zaBeW_TrO={t*D;sUDIOK4bc;`#}Is}ZN*%@ zYOP3GcL>%UN$Xz0x_5z1Si5GAteCCQEBD6d$79!*D|f7tH4n7+weiv)7B1BMxapIo z#r=u)o@Dzeq5ag-0RPf?{=#6Q{S|?Hg&!J84!MOPH%~E%Ayy#SRA#I-LGFT(NA>R1 z-u*uw|73jeT4HZ6YUsluWMZv=l~vY66)31O!yO`{A3VqH*pKF%* z!d&r1dDW_=I%#PVEKTv^WlJ+!m>M%#?i`*w9NV>A(zs%>Lxb5mt4zVdRViELtR`i$ zq(fFoQ>$QVjk5{U?pZulQ5n5BN5{KA?)#u`q5I*B$>uJhxhv6p2u)RO61z0YpC9Kty@^U6Z}EL$A!UKs`TdR*S^YqBUlYfFsE_ZAx5o;S zqGcK@Y+7+5M=I>MiO>F2$Fe|gz*{_~a{3#Nw`7mGd|S!5q||73a{!%`2z zP<~H8uaC9AU+^RktL|7cU}a`W>>Yl#goS*l`n4;=R$f_Xcz<%{ylf2%-0YT31D`rC?6D?Y2}TiThbZHo4!8k(Yg zzpQVF;i<-^2jTnSh2})#;TVx38y^(hFNk0Lc>06sg=-Jr_>4TfrotK;;pmceaxcA1 zw*RgWt2~bL6@6{ejfB=IF`K z8@I*xEY$w!jhHeubeVU)`gq92k9v9EgfQyoLz9n3CqHWXxaEVE5sG@=YNo& zZ0Z!6Iv0;U>i+b^l5(m0=W3y=pFew!A9!WC=^}sqHJ*zI*I$pRQsnj|*)EXn3;X_N z&m;3vJ%8@yMCS!z*WhR5D{C68X&)TAqj(>lJaX~zk&7|v!NmQEh3(4?hj^!NzHg}8g_^w!(~mTXn&VLoAS$g)E34I=dy+eQgq=Mp zdoB83+mLE(U7+~Jjx`lt`b{o!j1Mm8m@I)$pvuP`OBwyHK+)%LimEk)LY*xc<~ z(?IKgeYFFY!JvEmKij*FgBlgTw`kC$_-wmj@Sr}aQ4JR9lBSx$4ps614!J|w-`fj6 z@IgT)x)fz)C_|=|Mz(}TQ6uSPAZ=ezz*qV;5ZnVX290_X`$~NjS6SEk6_~2)YsI)i zWlax2u;@o{+Q}OMA^Kw&hr+WAx|yvh zaUA~@R GitHub source + JavaDoc link (if found) +# - .mc4 relative link -> GitHub source +Original source is located: +https://github.com/facelessuser/pymdown-extensions/blob/f64422f87c05031a8c8d62b1988bf76e8f65f27f/pymdownx/snippets.py +------- + +MIT license. + +Copyright (c) 2017 Isaac Muse + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +""" +class SnippetExtension(snippets.SnippetExtension): + + def extendMarkdown(self, md): + """Register the extension.""" + self.md = md + md.registerExtension(self) + config = self.getConfigs() + snippet = MCSnippetPreprocessor(config, md) + md.preprocessors.register(snippet, "snippet", 32) + +# add this snippet extension here +def on_config(config, **kwargs): + config.markdown_extensions.append(SnippetExtension()) + + +# We have to copy the parse_snippets method to add our own hook point +class MCSnippetPreprocessor(snippets.SnippetPreprocessor): + + # A processing step to modify links + def process_snippet(self, s_lines, snippet): + import re + from pathlib import Path + base_path = Path(snippet).parent # directory in which the snippet resides + cwd = Path().resolve() + + # Pattern to match anchors to relative files [anchor]: url + file_pattern = r'(?!https?:\/\/)([^)]+\.(java|mc4))' + pattern_anchor = re.compile(r'\[([a-zA-Z0-9_]+)\]: ' + file_pattern) + # collect all used link-targets + relative_anchors = {m[0]: m for line in s_lines for m in pattern_anchor.findall(line)} + + # Pattern to match relative markdown links: [text](url) + pattern_rel_link = re.compile(r'\[([^\]]+)\]\(' + file_pattern + r'(#\S+)?\)') + # Pattern to match relative markdown links: [text][anchor] + pattern_anchor_link = re.compile(r'\[([^\]]+)\]\[([a-zA-Z0-9_]+)\]') + + # Replace functions + def anchor_replacer(match): # [text][anchor] + text = match.group(1) # the text within the link + a_name = match.group(2) # the name of the anchor + if a_name not in relative_anchors: + return match.group(0) # keep original + anchor = relative_anchors[a_name] + return replace_link(text, anchor[1], anchor[2]) + + def link_replacer(match): # [text](url) links + text = match.group(1) # the text within the link + url = match.group(2) # the url including everything + file_ext = match.group(3) # the url including everything + anchor = match.group(4) or "" # an optional #anchor + return replace_link(text, url, file_ext, anchor) + + def replace_link(text, url, file_ext, anchor=""): + # which file does the url point to? + resolved_path = (base_path / url).resolve().relative_to(cwd) + # step 1: construct a GitHub link + github_link = f"https://github.com/MontiCore/cd4analysis/blob/dev/{resolved_path} \"View file on GitHub\"" + github_icon = f"[:material-github:{{ .nonhighlight}}]({github_link})" + # step 2: construct a JavaDocs link + parts = resolved_path.parts + project = parts[0] # the project, i.e. cdlang, cd2plantuml, cd2smt, cddiff, cdmerge, cdtool, language-server, symtabdefinitiontoll, cd-runtime + source_set = parts[2] # main or testFixtures + # we have links to non main/testFixtures java files -> no javadoc link + link = github_link + if source_set in ['main', 'testFixtures'] and project in ['cdlang', + 'cd2plantuml', + 'cd2smt', + 'cddiff', + 'cdmerge', + 'cdtool', + 'language-server', + 'symtabdefinitiontool', + 'cd-runtime'] and file_ext == 'java': + # find the correct file location + javadoc_task = 'javadoc' if source_set == 'main' else 'testFixturesJavadoc' + back_to_root = '../' * (len(base_path.relative_to(cwd).parts)) + file = '/'.join(parts[4:])[:-len(".java")] + javadoc_link = f"{back_to_root}{project}/{javadoc_task}/{file}.html{anchor} \"View JavaDoc\"" + javadoc_icon = f"[:material-file-document:{{ .nonhighlight }}]({javadoc_link})" + link = javadoc_link + else: + javadoc_icon = '' + return f"[{text}]({link}) {github_icon} {javadoc_icon}" + + # Apply replacement + return [pattern_anchor_link.sub(anchor_replacer, pattern_rel_link.sub(link_replacer, md_text)) for md_text in + s_lines] + + + # the following code is copied 1-to-1 (just with the addition of one hook) + """Handle snippets in Markdown content. - a copy of """ + def parse_snippets(self, lines, file_name=None, is_url=False, is_section=False): + """Parse snippets snippet.""" + + if file_name: + # Track this file. + self.seen.add(file_name) + + new_lines = [] + inline = False + block = False + for line in lines: + # Check for snippets on line + inline = False + m = self.RE_ALL_SNIPPETS.match(line) + if m: + if m.group('escape'): + # The snippet has been escaped, replace first `;` and continue. + new_lines.append(line.replace(';', '', 1)) + continue + + if block and m.group('inline_marker'): + # Don't use inline notation directly under a block. + # It's okay if inline is used again in sub file though. + continue + + elif m.group('inline_marker'): + # Inline + inline = True + + else: + # Block + block = not block + continue + + elif not block: + if not is_section: + # Check for section line, if present remove, if escaped, reformat it + m2 = self.RE_SNIPPET_SECTION.match(line) + if m2 and m2.group('escape'): + line = ( + m2.group('pre') + m2.group('escape').replace(';', '', 1) + m2.group('inline_marker') + + m2.group('section') + m2.group('post') + ) + m2 = None + + # Found a section that must be removed + if m2 is not None: + continue + + # Not in snippet, and we didn't find an inline, + # so just a normal line + new_lines.append(line) + continue + + if block and not inline: + # We are in a block and we didn't just find a nested inline + # So check if a block path + m = self.RE_SNIPPET.match(line) + + if m: + # Get spaces and snippet path. Remove quotes if inline. + space = m.group('space').expandtabs(self.tab_length) + path = m.group('snippet')[1:-1].strip() if inline else m.group('snippet').strip() + + if not inline: + # Block path handling + if not path: + # Empty path line, insert a blank line + new_lines.append('') + continue + + # Ignore commented out lines + if path.startswith(';'): + continue + + # Get line numbers (if specified) + end = [] + start = [] + section = None + m = self.RE_SNIPPET_FILE.match(path) + path = '' if m is None else m.group(1).strip() + # Looks like we have an empty file and only lines specified + if not path: + if self.check_paths: + raise snippets.SnippetMissingError(f"Snippet at path '{path}' could not be found") + else: + continue + if m.group(2): + for nums in m.group(2)[1:].split(','): + span = nums.split(':') + st = int(span[0]) if span[0] else None + start.append(st if st is None or st < 0 else max(0, st - 1)) + en = int(span[1]) if len(span) > 1 and span[1] else None + end.append(en) + elif m.group(3): + section = m.group(3)[1:] + + # Ignore path links if we are in external, downloaded content + is_link = path.lower().startswith(('https://', 'http://')) + if is_url and not is_link: + continue + + # If this is a link, and we are allowing URLs, set `url` to true. + # Make sure we don't process `path` as a local file reference. + url = self.url_download and is_link + snippet = self.get_snippet_path(path) if not url else path + + if snippet: + + # This is in the stack and we don't want an infinite loop! + if snippet in self.seen: + continue + + if not url: + # Read file content + with open(snippet, 'r', encoding=self.encoding) as f: + last = False + s_lines = [] + for l in f: + last = l.endswith(('\r', '\n')) + s_lines.append(l.strip('\r\n')) + if last: + s_lines.append('') + else: + # Read URL content + try: + s_lines = self.download(snippet) + except snippets.SnippetMissingError: + if self.check_paths: + raise + s_lines = [] + + if s_lines: + total = len(s_lines) + if start and end: + final_lines = [] + for sel in zip(start, end): + s_start = snippets.util.clamp(total + sel[0], 0, total) if sel[0] and sel[0] < 0 else sel[0] + s_end = snippets.util.clamp(total + 1 + sel[1], 0, total) if sel[1] and sel[1] < 0 else sel[1] + final_lines.extend(s_lines[slice(s_start, s_end, None)]) + s_lines = self.dedent(final_lines) if self.dedent_subsections else final_lines + elif section: + s_lines = self.extract_section(section, s_lines) + + # BEGIN MODIFICATION: Call hook point + if s_lines: + s_lines = self.process_snippet(s_lines, snippet) + # END MODIFICATION + + # Process lines looking for more snippets + new_lines.extend( + [ + space + l2 for l2 in self.parse_snippets( + s_lines, + snippet, + is_url=url, + is_section=section is not None + ) + ] + ) + + elif self.check_paths: + raise snippets.SnippetMissingError(f"Snippet at path '{path}' could not be found") + + # Pop the current file name out of the cache + if file_name: + self.seen.remove(file_name) + + return new_lines diff --git a/doc/owdiff_DT3_DT2_module.als b/docs/owdiff_DT3_DT2_module.als similarity index 100% rename from doc/owdiff_DT3_DT2_module.als rename to docs/owdiff_DT3_DT2_module.als diff --git a/docs/scripts/preprocessing.sh b/docs/scripts/preprocessing.sh new file mode 100644 index 000000000..924ff2a3b --- /dev/null +++ b/docs/scripts/preprocessing.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# (c) https://github.com/MontiCore/monticore +# script for all preprocessing steps of the pages job +# is used to have uniform bases for both gitlab and github pages +# +# remove all occurrences of '[[_TOC_]]' in markdown files +# because mkdocs already renders its own toc +case " $* " in + *" inplace "*) + for file in $(find ./docs/docs -type f -name "*.md") + do + sed -i 's/\[\[_TOC_\]\]//' $file + perl -pi -e 's/\[([^\[\]\(\)]*)\]\([^\[\]\(\)]*git.rwth-aachen.de[^\[\]\(\)]*?\)/$1/g' $file + done + echo "[INFO] Removed all occurrences of '[[_TOC_]]' in *.md files" + echo "[INFO] Removed all links to https://git.rwth-aachen.de in *.md files" + ;; +esac +# move all directories that contain *.md files to the docs folder +# because mkdocs can only find *.md files there +rm -r docs_wd || true + +case " $* " in + *" symlink "*) + # use symlinks to track updates + mkdir docs_wd + ln -s ../docs/overrides docs_wd/ + ln -s ../docs/stylesheets docs_wd/ + ln -s ../docs/scripts docs_wd/ + ln -s ../docs/img docs_wd/ + echo "[INFO] Using symlinks for live editing" + ;; + *) + cp -r docs docs_wd + rm docs_wd/*.md + cp README.md docs_wd/README.md + # all images referenced in the root-Readme must be handled specially :( + # mkdir -p docs_wd/docs/img + # cp docs/img/MC_Symp_Banner.png docs_wd/docs/img/MC_Symp_Banner.png + # echo "[INFO] Copied site design" + # Copy the javadoc directories for cd2plantuml, cd2smt, cd-runtime, cddiff, cdlang, cdmerge, cdtool, language-server, symtabdefinitiontool + mkdir -p docs_wd/cd2plantuml + cp -r cd2plantuml/target/docs/javadoc docs_wd/cd2plantuml/javadoc + cp -r cd2plantuml/target/docs/testFixturesJavadoc docs_wd/cd2plantuml/testFixturesJavadoc + mkdir -p docs_wd/cd2smt + cp -r cd2smt/target/docs/javadoc docs_wd/cd2smt/javadoc + cp -r cd2smt/target/docs/testFixturesJavadoc docs_wd/cd2smt/testFixturesJavadoc + mkdir -p docs_wd/cd-runtime + cp -r cd-runtime/target/docs/javadoc docs_wd/cd-runtime/javadoc + cp -r cd-runtime/target/docs/testFixturesJavadoc docs_wd/cd-runtime/testFixturesJavadoc + mkdir -p docs_wd/cddiff + cp -r cddiff/target/docs/javadoc docs_wd/cddiff/javadoc + cp -r cddiff/target/docs/testFixturesJavadoc docs_wd/cddiff/testFixturesJavadoc + mkdir -p docs_wd/cdlang + cp -r cdlang/target/docs/javadoc docs_wd/cdlang/javadoc + cp -r cdlang/target/docs/testFixturesJavadoc docs_wd/cdlang/testFixturesJavadoc + mkdir -p docs_wd/cdmerge + cp -r cdmerge/target/docs/javadoc docs_wd/cdmerge/javadoc + cp -r cdmerge/target/docs/testFixturesJavadoc docs_wd/cdmerge/testFixturesJavadoc + mkdir -p docs_wd/cdtool + cp -r cdtool/target/docs/javadoc docs_wd/cdtool/javadoc + cp -r cdtool/target/docs/testFixturesJavadoc docs_wd/cdtool/testFixturesJavadoc + mkdir -p docs_wd/language-server + cp -r language-server/target/docs/javadoc docs_wd/language-server/javadoc + cp -r language-server/target/docs/testFixturesJavadoc docs_wd/language-server/testFixturesJavadoc + mkdir -p docs_wd/symtabdefinitiontool + cp -r symtabdefinitiontool/target/docs/javadoc docs_wd/symtabdefinitiontool/javadoc + cp -r symtabdefinitiontool/target/docs/testFixturesJavadoc docs_wd/symtabdefinitiontool/testFixturesJavadoc + echo "[INFO] Copied JavaDocs" + ;; +esac + + +for SOURCE_DIR in "docs" "cd2plantuml/src" "cd2smt/src" "cd-runtime/src" "cddiff/src" "cdlang/src" "cdmerge/src" "cdtool/src" "language-server/src" "symtabdefinitiontool/src"; do + # We link to java & mc4 files in our md files - which is why we have to redirect them too + find "$SOURCE_DIR" -type f \( -name "*.md" \) | while read -r filepath; do + target_file="docs_wd/$filepath" + mkdir -p "$(dirname "$target_file")" + # use snippets to include the original files content + if [ ! -f "$target_file" ]; then + echo "--8<-- \"$filepath\"" > "$target_file" + fi + done +done +echo "[INFO] Created snippet files" + +# the landing page snippet has to be removed again +# rm docs_wd/docs/README.md diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css new file mode 100644 index 000000000..f3796f0b9 --- /dev/null +++ b/docs/stylesheets/extra.css @@ -0,0 +1,25 @@ +/* (c) https://github.com/MontiCore/monticore */ +.md-header { + background-color: #006BA5; +} +:root { + --md-primary-fg-color: #006BA5; +} +.tip { + border: 2px solid grey; + border-radius: 5px; + padding: 10px; + margin-bottom: 5px; +} +.tip-header { + font-size: larger; + border-bottom: 2px solid grey; +} +.bibliography { + empty-cells: hide; +} + +/* Reduce icon intensity*/ +.nonhighlight { + color: color-mix(in srgb, currentColor 50%, transparent); +} diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 000000000..5a441638e --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,78 @@ +site_name: CD4Analysis +theme: + name: 'material' + favicon: 'img/favicon.ico' + custom_dir: docs/overrides + hide: + - navigation + features: + - navigation.tabs + - toc.integrate + - toc.follow + - content.tabs.link + - content.code.copy + - navigation.instant # search index survives navigation + icon: + logo: 'fontawesome/solid/desktop' + +site_url: https://monticore.github.io/cd4analysis/ +repo_url: https://github.com/MontiCore/cd4analysis/ +edit_uri: "" + +extra_css: + - 'stylesheets/extra.css' + +copyright: '(c) https://github.com/MontiCore/monticore' + +markdown_extensions: + - admonition + - attr_list + - pymdownx.highlight + - pymdownx.inlinehilite + - pymdownx.details + - pymdownx.superfences + # pymdownx.snippets is added by the docsnippet hook! + - pymdownx.tabbed: + alternate_style: true + - pymdownx.emoji: + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg + +hooks: + - docs/overrides/extensions/docsnippet.py + +plugins: + - search + +nav: + - Home: 'README.md' + - 'Getting Started': 'docs/GettingStarted.md' +# - Core Grammars: +# - 'Overview': 'monticore-grammar/src/main/grammars/de/monticore/Grammars.md' +# - 'Expressions': 'monticore-grammar/src/main/grammars/de/monticore/expressions/Expressions.md' +# - 'Literals': 'monticore-grammar/src/main/grammars/de/monticore/literals/Literals.md' +# - 'Types': 'monticore-grammar/src/main/grammars/de/monticore/types/Types.md' +# - Languages: +# - 'Languages and Language Components': 'docs/DevelopedLanguages.md' +# - 'List of Languages': 'docs/Languages.md' +# - 'Best Practices': 'docs/BestPractices.md' +# - Changelog: '00.org/Explanations/CHANGELOG.md' +# - Downloads: 'docs/Download.md' +# - Publications: 'docs/Publications.md' +# - License: '00.org/Licenses/LICENSE-MONTICORE-3-LEVEL.md' + +# run `docs/scripts/preprocessing.sh symlink` to create this directory locally +docs_dir: docs_wd + +watch: + - docs + - cd2plantuml/src + - cd2smt/src + - cd-runtime/src + - cddiff/src + - cdlang/src + - cdmerge/src + - cdtool/src + - language-server/src + - symtabdefinitiontool/src + - README.md \ No newline at end of file From 0586198c9de24062711e62c6b3707d5503c75fad Mon Sep 17 00:00:00 2001 From: Hendrik7889 <44064629+Hendrik7889@users.noreply.github.com> Date: Mon, 1 Jun 2026 17:10:38 +0200 Subject: [PATCH 03/14] add svgs cds with decorators --- .../java/de/monticore/cdgen/CDGenTool.java | 21 +- docs/MyLifeNoDecorators.cd | 79 ++ docs/MyLifeNoDecorators.svg | 587 ++++++++++++ docs/MyLifeOnlyBuilders.cd | 198 ++++ docs/MyLifeOnlyBuilders.svg | 860 ++++++++++++++++++ docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd | 82 ++ .../MyLifeOnlyDefaultsForCardinalityAttrs.svg | 587 ++++++++++++ docs/MyLifeOnlyGetter.cd | 154 ++++ docs/MyLifeOnlyGetter.svg | 744 +++++++++++++++ docs/MyLifeOnlyNavigableSetter.cd | 103 +++ docs/MyLifeOnlyNavigableSetter.svg | 642 +++++++++++++ docs/MyLifeOnlyObservers.cd | 183 ++++ docs/MyLifeOnlyObservers.svg | 844 +++++++++++++++++ docs/MyLifeOnlySetter.cd | 103 +++ docs/MyLifeOnlySetter.svg | 642 +++++++++++++ docs/MyLifeOnlyVisitors.cd | 182 ++++ docs/MyLifeOnlyVisitors.svg | 820 +++++++++++++++++ .../MyLifeOnlyWithAbstractMethodSignatures.cd | 79 ++ ...MyLifeOnlyWithAbstractMethodSignatures.svg | 587 ++++++++++++ 19 files changed, 7491 insertions(+), 6 deletions(-) create mode 100644 docs/MyLifeNoDecorators.cd create mode 100644 docs/MyLifeNoDecorators.svg create mode 100644 docs/MyLifeOnlyBuilders.cd create mode 100644 docs/MyLifeOnlyBuilders.svg create mode 100644 docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd create mode 100644 docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg create mode 100644 docs/MyLifeOnlyGetter.cd create mode 100644 docs/MyLifeOnlyGetter.svg create mode 100644 docs/MyLifeOnlyNavigableSetter.cd create mode 100644 docs/MyLifeOnlyNavigableSetter.svg create mode 100644 docs/MyLifeOnlyObservers.cd create mode 100644 docs/MyLifeOnlyObservers.svg create mode 100644 docs/MyLifeOnlySetter.cd create mode 100644 docs/MyLifeOnlySetter.svg create mode 100644 docs/MyLifeOnlyVisitors.cd create mode 100644 docs/MyLifeOnlyVisitors.svg create mode 100644 docs/MyLifeOnlyWithAbstractMethodSignatures.cd create mode 100644 docs/MyLifeOnlyWithAbstractMethodSignatures.svg diff --git a/cdlang/src/main/java/de/monticore/cdgen/CDGenTool.java b/cdlang/src/main/java/de/monticore/cdgen/CDGenTool.java index 4bb9f5b26..ea3f79bb1 100644 --- a/cdlang/src/main/java/de/monticore/cdgen/CDGenTool.java +++ b/cdlang/src/main/java/de/monticore/cdgen/CDGenTool.java @@ -150,7 +150,7 @@ else if (!cmd.hasOption("i") || cmd.hasOption("h")) { } } - if (cmd.hasOption("o")) { + if (cmd.hasOption("o") || cmd.hasOption("pp")) { // Where to load additional templates from List additionalTemplatePaths = cmd.hasOption("fp") ? Arrays.stream(cmd .getOptionValues("fp")).map(Paths::get).map(Path::toFile).collect(Collectors.toList()) @@ -182,7 +182,10 @@ else if (!cmd.hasOption("i") || cmd.hasOption("h")) { // If required, we also output the symbol table of the *decorated* AST this.createAndExportDecoratedSymbolTable(decorated, cmd.getOptionValue("sd")); } - }, asts); + if(cmd.hasOption("pp")){ + this.prettyPrint(decorated, Paths.get(cmd.getOptionValue("pp")).toString()); + } + }, asts, cmd.hasOption("o")); } } catch (ParseException e) { @@ -224,7 +227,7 @@ public void initializeDecConf(GlobalExtensionManagement glex, DecoratorConfig de public void decorateAndGenerate(GlobalExtensionManagement glex, Consumer initializeDecConf, GeneratorSetup setup, Runnable initDecoratedGlobalScope, Consumer postDecorate, - Collection asts) { + Collection asts, boolean doGenerate) { glex.setGlobalValue("cdPrinter", new CdUtilsPrinter()); glex.setGlobalValue("mcTypeFacade", MCTypeFacade.getInstance()); // TODO: Remove from templates glex.setGlobalValue("cdGenService", new CDGenService()); @@ -272,7 +275,9 @@ public void decorateAndGenerate(GlobalExtensionManagement glex, topTransformer.addToTraverser(t); decorated.get().accept(t); - generator.generate(decorated.get()); + if(doGenerate) { + generator.generate(decorated.get()); + } } } @@ -373,7 +378,11 @@ public Options addAdditionalOptions(Options options) { options.addOption(org.apache.commons.cli.Option.builder("sd").longOpt("symboltabledecorated") .argName("file").hasArg().desc( "Serializes the decorated symbol table of the given artifact.").build()); - + + options.addOption(org.apache.commons.cli.Option.builder("pp").longOpt("prettyprint") + .argName("file").hasArg().desc( + "Pretty prints the decorated AST to the given file.").build()); + return options; } @@ -435,4 +444,4 @@ public void mapCD4CImports(ASTCDCompilationUnit ast) { } } -} +} \ No newline at end of file diff --git a/docs/MyLifeNoDecorators.cd b/docs/MyLifeNoDecorators.cd new file mode 100644 index 000000000..39fae065b --- /dev/null +++ b/docs/MyLifeNoDecorators.cd @@ -0,0 +1,79 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + public String name; + public Date birthDate; + public String email; + + } + public abstract class Asset { + public String assetId; + public Date createdDate; + public Priority priority; + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + public String employeeId; + public double salary; + public Status employmentStatus; + public Listresponsibilities; + + } + public class Project extends Asset { + public String projectName; + public Date deadline; + public Listmilestones; + + } + public class Task extends Asset { + public String taskName; + public String description; + public Status taskStatus; + + } + public class Team { + public String teamName; + public int teamSize; + public ListteamMembers; + + } + public class Department { + public String deptName; + public String location; + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + + } + +} diff --git a/docs/MyLifeNoDecorators.svg b/docs/MyLifeNoDecorators.svg new file mode 100644 index 000000000..9ec00d981 --- /dev/null +++ b/docs/MyLifeNoDecorators.svg @@ -0,0 +1,587 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + + String name; + + + Date birthDate; + + + String email; + + + + + + + + MyLife + + Β«abstractΒ» + Asset + + + + String assetId; + + + Date createdDate; + + + Priority priority; + + + + + + + + MyLife + + + Employee + + + + String employeeId; + + + double salary; + + + Status employmentStatus; + + + List<Priority>responsibilities; + + + + + + + + MyLife + + + Project + + + + String projectName; + + + Date deadline; + + + List<String>milestones; + + + + + + + + MyLife + + + Task + + + + String taskName; + + + String description; + + + Status taskStatus; + + + + + + + + MyLife + + + Team + + + + String teamName; + + + int teamSize; + + + List<String>teamMembers; + + + + + + + + MyLife + + + Department + + + + String deptName; + + + String location; + + + + + + + + CD + + + diff --git a/docs/MyLifeOnlyBuilders.cd b/docs/MyLifeOnlyBuilders.cd new file mode 100644 index 000000000..1c03425e1 --- /dev/null +++ b/docs/MyLifeOnlyBuilders.cd @@ -0,0 +1,198 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + public String name; + public Date birthDate; + public String email; + + } + public abstract class Asset { + public String assetId; + public Date createdDate; + public Priority priority; + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + public String employeeId; + public double salary; + public Status employmentStatus; + public Listresponsibilities; + + } + public class Project extends Asset { + public String projectName; + public Date deadline; + public Listmilestones; + + } + public class Task extends Asset { + public String taskName; + public String description; + public Status taskStatus; + + } + public class Team { + public String teamName; + public int teamSize; + public ListteamMembers; + + } + public class Department { + public String deptName; + public String location; + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + public abstract class PersonBuilder { + protected PersonBuilder realBuilder; + public PersonBuilder(); + private boolean isValid(); + public Person build(); + public Person unsafeBuild(); + protected String name; + protected Date birthDate; + protected String email; + public PersonBuilder setName(String name); + public PersonBuilder setBirthDate(Date birthDate); + public PersonBuilder setEmail(String email); + + } + public abstract class AssetBuilder { + protected AssetBuilder realBuilder; + public AssetBuilder(); + private boolean isValid(); + public Asset build(); + public Asset unsafeBuild(); + protected String assetId; + protected Date createdDate; + protected Priority priority; + public AssetBuilder setAssetId(String assetId); + public AssetBuilder setCreatedDate(Date createdDate); + public AssetBuilder setPriority(Priority priority); + + } + public class EmployeeBuilder { + protected EmployeeBuilder realBuilder; + public EmployeeBuilder(); + private boolean isValid(); + public Employee build(); + public Employee unsafeBuild(); + protected String employeeId; + protected double salary; + protected Status employmentStatus; + protected Listresponsibilities; + protected String name; + protected Date birthDate; + protected String email; + public EmployeeBuilder setEmployeeId(String employeeId); + public EmployeeBuilder setSalary(double salary); + public EmployeeBuilder setEmploymentStatus(Status employmentStatus); + public EmployeeBuilder setResponsibilities(Listresponsibilities); + public EmployeeBuilder setName(String name); + public EmployeeBuilder setBirthDate(Date birthDate); + public EmployeeBuilder setEmail(String email); + public EmployeeBuilder setResponsibilitiesAbsent(); + + } + public class ProjectBuilder { + protected ProjectBuilder realBuilder; + public ProjectBuilder(); + private boolean isValid(); + public Project build(); + public Project unsafeBuild(); + protected String projectName; + protected Date deadline; + protected Listmilestones; + protected String assetId; + protected Date createdDate; + protected Priority priority; + public ProjectBuilder setProjectName(String projectName); + public ProjectBuilder setDeadline(Date deadline); + public ProjectBuilder setMilestones(Listmilestones); + public ProjectBuilder setAssetId(String assetId); + public ProjectBuilder setCreatedDate(Date createdDate); + public ProjectBuilder setPriority(Priority priority); + public ProjectBuilder setMilestonesAbsent(); + + } + public class TaskBuilder { + protected TaskBuilder realBuilder; + public TaskBuilder(); + private boolean isValid(); + public Task build(); + public Task unsafeBuild(); + protected String taskName; + protected String description; + protected Status taskStatus; + protected String assetId; + protected Date createdDate; + protected Priority priority; + public TaskBuilder setTaskName(String taskName); + public TaskBuilder setDescription(String description); + public TaskBuilder setTaskStatus(Status taskStatus); + public TaskBuilder setAssetId(String assetId); + public TaskBuilder setCreatedDate(Date createdDate); + public TaskBuilder setPriority(Priority priority); + + } + public class TeamBuilder { + protected TeamBuilder realBuilder; + public TeamBuilder(); + private boolean isValid(); + public Team build(); + public Team unsafeBuild(); + protected String teamName; + protected int teamSize; + protected ListteamMembers; + public TeamBuilder setTeamName(String teamName); + public TeamBuilder setTeamSize(int teamSize); + public TeamBuilder setTeamMembers(ListteamMembers); + public TeamBuilder setTeamMembersAbsent(); + + } + public class DepartmentBuilder { + protected DepartmentBuilder realBuilder; + public DepartmentBuilder(); + private boolean isValid(); + public Department build(); + public Department unsafeBuild(); + protected String deptName; + protected String location; + public DepartmentBuilder setDeptName(String deptName); + public DepartmentBuilder setLocation(String location); + + } + + } + +} diff --git a/docs/MyLifeOnlyBuilders.svg b/docs/MyLifeOnlyBuilders.svg new file mode 100644 index 000000000..5507c4cf3 --- /dev/null +++ b/docs/MyLifeOnlyBuilders.svg @@ -0,0 +1,860 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + + String name; + + + Date birthDate; + + + String email; + + + + + + + + MyLife + + Β«abstractΒ» + Asset + + + + String assetId; + + + Date createdDate; + + + Priority priority; + + + + + + + + MyLife + + + Employee + + + + String employeeId; + + + double salary; + + + Status employmentStatus; + + + List<Priority>responsibilities; + + + + + + + + MyLife + + + Project + + + + String projectName; + + + Date deadline; + + + List<String>milestones; + + + + + + + + MyLife + + + Task + + + + String taskName; + + + String description; + + + Status taskStatus; + + + + + + + + MyLife + + + Team + + + + String teamName; + + + int teamSize; + + + List<String>teamMembers; + + + + + + + + MyLife + + + Department + + + + String deptName; + + + String location; + + + + + + + + MyLife + + Β«abstractΒ» + PersonBuilder + + + # PersonBuilder realBuilder; + + # String name; + + # Date birthDate; + + # String email; + + + + + - boolean isValid(); + + + Person build(); + + + Person unsafeBuild(); + + + PersonBuilder setName(String name); + + + PersonBuilder setBirthDate(Date birthDate); + + + PersonBuilder setEmail(String email); + + + + + + MyLife + + Β«abstractΒ» + AssetBuilder + + + # AssetBuilder realBuilder; + + # String assetId; + + # Date createdDate; + + # Priority priority; + + + + + - boolean isValid(); + + + Asset build(); + + + Asset unsafeBuild(); + + + AssetBuilder setAssetId(String assetId); + + + AssetBuilder setCreatedDate(Date createdDate); + + + AssetBuilder setPriority(Priority priority); + + + + + + MyLife + + + EmployeeBuilder + + + # EmployeeBuilder realBuilder; + + # String employeeId; + + # double salary; + + # Status employmentStatus; + + # List<Priority>responsibilities; + + # String name; + + # Date birthDate; + + # String email; + + + + + - boolean isValid(); + + + Employee build(); + + + Employee unsafeBuild(); + + + EmployeeBuilder setEmployeeId(String employeeId); + + + EmployeeBuilder setSalary(double salary); + + + EmployeeBuilder setEmploymentStatus(Status employmentStatus); + + + EmployeeBuilder setResponsibilities(List<Priority>responsibilities); + + + EmployeeBuilder setName(String name); + + + EmployeeBuilder setBirthDate(Date birthDate); + + + EmployeeBuilder setEmail(String email); + + + EmployeeBuilder setResponsibilitiesAbsent(); + + + + + + MyLife + + + ProjectBuilder + + + # ProjectBuilder realBuilder; + + # String projectName; + + # Date deadline; + + # List<String>milestones; + + # String assetId; + + # Date createdDate; + + # Priority priority; + + + + + - boolean isValid(); + + + Project build(); + + + Project unsafeBuild(); + + + ProjectBuilder setProjectName(String projectName); + + + ProjectBuilder setDeadline(Date deadline); + + + ProjectBuilder setMilestones(List<String>milestones); + + + ProjectBuilder setAssetId(String assetId); + + + ProjectBuilder setCreatedDate(Date createdDate); + + + ProjectBuilder setPriority(Priority priority); + + + ProjectBuilder setMilestonesAbsent(); + + + + + + MyLife + + + TaskBuilder + + + # TaskBuilder realBuilder; + + # String taskName; + + # String description; + + # Status taskStatus; + + # String assetId; + + # Date createdDate; + + # Priority priority; + + + + + - boolean isValid(); + + + Task build(); + + + Task unsafeBuild(); + + + TaskBuilder setTaskName(String taskName); + + + TaskBuilder setDescription(String description); + + + TaskBuilder setTaskStatus(Status taskStatus); + + + TaskBuilder setAssetId(String assetId); + + + TaskBuilder setCreatedDate(Date createdDate); + + + TaskBuilder setPriority(Priority priority); + + + + + + MyLife + + + TeamBuilder + + + # TeamBuilder realBuilder; + + # String teamName; + + # int teamSize; + + # List<String>teamMembers; + + + + + - boolean isValid(); + + + Team build(); + + + Team unsafeBuild(); + + + TeamBuilder setTeamName(String teamName); + + + TeamBuilder setTeamSize(int teamSize); + + + TeamBuilder setTeamMembers(List<String>teamMembers); + + + TeamBuilder setTeamMembersAbsent(); + + + + + + MyLife + + + DepartmentBuilder + + + # DepartmentBuilder realBuilder; + + # String deptName; + + # String location; + + + + + - boolean isValid(); + + + Department build(); + + + Department unsafeBuild(); + + + DepartmentBuilder setDeptName(String deptName); + + + DepartmentBuilder setLocation(String location); + + + + + + CD + + + diff --git a/docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd b/docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd new file mode 100644 index 000000000..3de03524f --- /dev/null +++ b/docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd @@ -0,0 +1,82 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + public String name; + public Date birthDate; + public String email; + + } + public abstract class Asset { + public String assetId; + public Date createdDate; + public Priority priority; + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + public String employeeId; + public double salary; + public Status employmentStatus; + public Listresponsibilities; + public Employee(); + + } + public class Project extends Asset { + public String projectName; + public Date deadline; + public Listmilestones; + public Project(); + + } + public class Task extends Asset { + public String taskName; + public String description; + public Status taskStatus; + + } + public class Team { + public String teamName; + public int teamSize; + public ListteamMembers; + public Team(); + + } + public class Department { + public String deptName; + public String location; + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + + } + +} diff --git a/docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg b/docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg new file mode 100644 index 000000000..9ec00d981 --- /dev/null +++ b/docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg @@ -0,0 +1,587 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + + String name; + + + Date birthDate; + + + String email; + + + + + + + + MyLife + + Β«abstractΒ» + Asset + + + + String assetId; + + + Date createdDate; + + + Priority priority; + + + + + + + + MyLife + + + Employee + + + + String employeeId; + + + double salary; + + + Status employmentStatus; + + + List<Priority>responsibilities; + + + + + + + + MyLife + + + Project + + + + String projectName; + + + Date deadline; + + + List<String>milestones; + + + + + + + + MyLife + + + Task + + + + String taskName; + + + String description; + + + Status taskStatus; + + + + + + + + MyLife + + + Team + + + + String teamName; + + + int teamSize; + + + List<String>teamMembers; + + + + + + + + MyLife + + + Department + + + + String deptName; + + + String location; + + + + + + + + CD + + + diff --git a/docs/MyLifeOnlyGetter.cd b/docs/MyLifeOnlyGetter.cd new file mode 100644 index 000000000..f2cb53ef0 --- /dev/null +++ b/docs/MyLifeOnlyGetter.cd @@ -0,0 +1,154 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + protected String name; + protected Date birthDate; + protected String email; + public String getName(); + public Date getBirthDate(); + public String getEmail(); + + } + public abstract class Asset { + protected String assetId; + protected Date createdDate; + protected Priority priority; + public String getAssetId(); + public Date getCreatedDate(); + public Priority getPriority(); + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + protected String employeeId; + protected double salary; + protected Status employmentStatus; + protected Listresponsibilities; + public String getEmployeeId(); + public double getSalary(); + public Status getEmploymentStatus(); + public ListgetResponsibilities(); + public boolean containsResponsibilities(Object element); + public boolean containsAllResponsibilities(java.util.Collectioncollection); + public boolean isEmptyResponsibilities(); + public java.util.IteratoriteratorResponsibilities(); + public int sizeResponsibilities(); + public Priority []toArrayResponsibilities(Priority []array); + public Object []toArrayResponsibilities(); + public java.util.SpliteratorspliteratorResponsibilities(); + public java.util.stream.StreamstreamResponsibilities(); + public java.util.stream.StreamparallelStreamResponsibilities(); + public boolean equalsResponsibilities(Object o); + public int hashCodeResponsibilities(); + public Priority getResponsibilities(int index); + public int indexOfResponsibilities(Object element); + public int lastIndexOfResponsibilities(Object element); + public java.util.ListIteratorlistIteratorResponsibilities(); + public java.util.ListIteratorlistIteratorResponsibilities(int index); + public java.util.ListsubListResponsibilities(int start,int end); + + } + public class Project extends Asset { + protected String projectName; + protected Date deadline; + protected Listmilestones; + public String getProjectName(); + public Date getDeadline(); + public ListgetMilestones(); + public boolean containsMilestones(Object element); + public boolean containsAllMilestones(java.util.Collectioncollection); + public boolean isEmptyMilestones(); + public java.util.IteratoriteratorMilestones(); + public int sizeMilestones(); + public String []toArrayMilestones(String []array); + public Object []toArrayMilestones(); + public java.util.SpliteratorspliteratorMilestones(); + public java.util.stream.StreamstreamMilestones(); + public java.util.stream.StreamparallelStreamMilestones(); + public boolean equalsMilestones(Object o); + public int hashCodeMilestones(); + public String getMilestones(int index); + public int indexOfMilestones(Object element); + public int lastIndexOfMilestones(Object element); + public java.util.ListIteratorlistIteratorMilestones(); + public java.util.ListIteratorlistIteratorMilestones(int index); + public java.util.ListsubListMilestones(int start,int end); + + } + public class Task extends Asset { + protected String taskName; + protected String description; + protected Status taskStatus; + public String getTaskName(); + public String getDescription(); + public Status getTaskStatus(); + + } + public class Team { + protected String teamName; + protected int teamSize; + protected ListteamMembers; + public String getTeamName(); + public int getTeamSize(); + public ListgetTeamMembers(); + public boolean containsTeamMembers(Object element); + public boolean containsAllTeamMembers(java.util.Collectioncollection); + public boolean isEmptyTeamMembers(); + public java.util.IteratoriteratorTeamMembers(); + public int sizeTeamMembers(); + public String []toArrayTeamMembers(String []array); + public Object []toArrayTeamMembers(); + public java.util.SpliteratorspliteratorTeamMembers(); + public java.util.stream.StreamstreamTeamMembers(); + public java.util.stream.StreamparallelStreamTeamMembers(); + public boolean equalsTeamMembers(Object o); + public int hashCodeTeamMembers(); + public String getTeamMembers(int index); + public int indexOfTeamMembers(Object element); + public int lastIndexOfTeamMembers(Object element); + public java.util.ListIteratorlistIteratorTeamMembers(); + public java.util.ListIteratorlistIteratorTeamMembers(int index); + public java.util.ListsubListTeamMembers(int start,int end); + + } + public class Department { + protected String deptName; + protected String location; + public String getDeptName(); + public String getLocation(); + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + + } + +} diff --git a/docs/MyLifeOnlyGetter.svg b/docs/MyLifeOnlyGetter.svg new file mode 100644 index 000000000..d4c0bea93 --- /dev/null +++ b/docs/MyLifeOnlyGetter.svg @@ -0,0 +1,744 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + # String name; + + # Date birthDate; + + # String email; + + + + + + String getName(); + + + Date getBirthDate(); + + + String getEmail(); + + + + + + MyLife + + Β«abstractΒ» + Asset + + + # String assetId; + + # Date createdDate; + + # Priority priority; + + + + + + String getAssetId(); + + + Date getCreatedDate(); + + + Priority getPriority(); + + + + + + MyLife + + + Employee + + + # String employeeId; + + # double salary; + + # Status employmentStatus; + + # List<Priority>responsibilities; + + + + + + String getEmployeeId(); + + + double getSalary(); + + + Status getEmploymentStatus(); + + + List<Priority>getResponsibilities(); + + + boolean containsResponsibilities(Object element); + + + boolean containsAllResponsibilities(java.util.Collection<?>collection); + + + boolean isEmptyResponsibilities(); + + + java.util.Iterator<Priority>iteratorResponsibilities(); + + + int sizeResponsibilities(); + + + Priority []toArrayResponsibilities(Priority []array); + + + Object []toArrayResponsibilities(); + + + java.util.Spliterator<Priority>spliteratorResponsibilities(); + + + java.util.stream.Stream<Priority>streamResponsibilities(); + + + java.util.stream.Stream<Priority>parallelStreamResponsibilities(); + + + boolean equalsResponsibilities(Object o); + + + int hashCodeResponsibilities(); + + + Priority getResponsibilities(int index); + + + int indexOfResponsibilities(Object element); + + + int lastIndexOfResponsibilities(Object element); + + + java.util.ListIterator<Priority>listIteratorResponsibilities(); + + + java.util.ListIterator<Priority>listIteratorResponsibilities(int index); + + + java.util.List<Priority>subListResponsibilities(int start,int end); + + + + + + MyLife + + + Project + + + # String projectName; + + # Date deadline; + + # List<String>milestones; + + + + + + String getProjectName(); + + + Date getDeadline(); + + + List<String>getMilestones(); + + + boolean containsMilestones(Object element); + + + boolean containsAllMilestones(java.util.Collection<?>collection); + + + boolean isEmptyMilestones(); + + + java.util.Iterator<String>iteratorMilestones(); + + + int sizeMilestones(); + + + String []toArrayMilestones(String []array); + + + Object []toArrayMilestones(); + + + java.util.Spliterator<String>spliteratorMilestones(); + + + java.util.stream.Stream<String>streamMilestones(); + + + java.util.stream.Stream<String>parallelStreamMilestones(); + + + boolean equalsMilestones(Object o); + + + int hashCodeMilestones(); + + + String getMilestones(int index); + + + int indexOfMilestones(Object element); + + + int lastIndexOfMilestones(Object element); + + + java.util.ListIterator<String>listIteratorMilestones(); + + + java.util.ListIterator<String>listIteratorMilestones(int index); + + + java.util.List<String>subListMilestones(int start,int end); + + + + + + MyLife + + + Task + + + # String taskName; + + # String description; + + # Status taskStatus; + + + + + + String getTaskName(); + + + String getDescription(); + + + Status getTaskStatus(); + + + + + + MyLife + + + Team + + + # String teamName; + + # int teamSize; + + # List<String>teamMembers; + + + + + + String getTeamName(); + + + int getTeamSize(); + + + List<String>getTeamMembers(); + + + boolean containsTeamMembers(Object element); + + + boolean containsAllTeamMembers(java.util.Collection<?>collection); + + + boolean isEmptyTeamMembers(); + + + java.util.Iterator<String>iteratorTeamMembers(); + + + int sizeTeamMembers(); + + + String []toArrayTeamMembers(String []array); + + + Object []toArrayTeamMembers(); + + + java.util.Spliterator<String>spliteratorTeamMembers(); + + + java.util.stream.Stream<String>streamTeamMembers(); + + + java.util.stream.Stream<String>parallelStreamTeamMembers(); + + + boolean equalsTeamMembers(Object o); + + + int hashCodeTeamMembers(); + + + String getTeamMembers(int index); + + + int indexOfTeamMembers(Object element); + + + int lastIndexOfTeamMembers(Object element); + + + java.util.ListIterator<String>listIteratorTeamMembers(); + + + java.util.ListIterator<String>listIteratorTeamMembers(int index); + + + java.util.List<String>subListTeamMembers(int start,int end); + + + + + + MyLife + + + Department + + + # String deptName; + + # String location; + + + + + + String getDeptName(); + + + String getLocation(); + + + + + + CD + + + diff --git a/docs/MyLifeOnlyNavigableSetter.cd b/docs/MyLifeOnlyNavigableSetter.cd new file mode 100644 index 000000000..d49793f87 --- /dev/null +++ b/docs/MyLifeOnlyNavigableSetter.cd @@ -0,0 +1,103 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + protected String name; + protected Date birthDate; + protected String email; + public void setName(String name); + public void setBirthDate(Date birthDate); + public void setEmail(String email); + + } + public abstract class Asset { + protected String assetId; + protected Date createdDate; + protected Priority priority; + public void setAssetId(String assetId); + public void setCreatedDate(Date createdDate); + public void setPriority(Priority priority); + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + protected String employeeId; + protected double salary; + protected Status employmentStatus; + protected Listresponsibilities; + public void setEmployeeId(String employeeId); + public void setSalary(double salary); + public void setEmploymentStatus(Status employmentStatus); + public void addResponsibilities(int index,Priority responsibilities); + public Priority removeResponsibilities(int index); + + } + public class Project extends Asset { + protected String projectName; + protected Date deadline; + protected Listmilestones; + public void setProjectName(String projectName); + public void setDeadline(Date deadline); + public void addMilestones(int index,String milestones); + public String removeMilestones(int index); + + } + public class Task extends Asset { + protected String taskName; + protected String description; + protected Status taskStatus; + public void setTaskName(String taskName); + public void setDescription(String description); + public void setTaskStatus(Status taskStatus); + + } + public class Team { + protected String teamName; + protected int teamSize; + protected ListteamMembers; + public void setTeamName(String teamName); + public void setTeamSize(int teamSize); + public void addTeamMembers(int index,String teamMembers); + public String removeTeamMembers(int index); + + } + public class Department { + protected String deptName; + protected String location; + public void setDeptName(String deptName); + public void setLocation(String location); + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + + } + +} diff --git a/docs/MyLifeOnlyNavigableSetter.svg b/docs/MyLifeOnlyNavigableSetter.svg new file mode 100644 index 000000000..0e486e474 --- /dev/null +++ b/docs/MyLifeOnlyNavigableSetter.svg @@ -0,0 +1,642 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + # String name; + + # Date birthDate; + + # String email; + + + + + + void setName(String name); + + + void setBirthDate(Date birthDate); + + + void setEmail(String email); + + + + + + MyLife + + Β«abstractΒ» + Asset + + + # String assetId; + + # Date createdDate; + + # Priority priority; + + + + + + void setAssetId(String assetId); + + + void setCreatedDate(Date createdDate); + + + void setPriority(Priority priority); + + + + + + MyLife + + + Employee + + + # String employeeId; + + # double salary; + + # Status employmentStatus; + + # List<Priority>responsibilities; + + + + + + void setEmployeeId(String employeeId); + + + void setSalary(double salary); + + + void setEmploymentStatus(Status employmentStatus); + + + void addResponsibilities(int index,Priority responsibilities); + + + Priority removeResponsibilities(int index); + + + + + + MyLife + + + Project + + + # String projectName; + + # Date deadline; + + # List<String>milestones; + + + + + + void setProjectName(String projectName); + + + void setDeadline(Date deadline); + + + void addMilestones(int index,String milestones); + + + String removeMilestones(int index); + + + + + + MyLife + + + Task + + + # String taskName; + + # String description; + + # Status taskStatus; + + + + + + void setTaskName(String taskName); + + + void setDescription(String description); + + + void setTaskStatus(Status taskStatus); + + + + + + MyLife + + + Team + + + # String teamName; + + # int teamSize; + + # List<String>teamMembers; + + + + + + void setTeamName(String teamName); + + + void setTeamSize(int teamSize); + + + void addTeamMembers(int index,String teamMembers); + + + String removeTeamMembers(int index); + + + + + + MyLife + + + Department + + + # String deptName; + + # String location; + + + + + + void setDeptName(String deptName); + + + void setLocation(String location); + + + + + + CD + + + diff --git a/docs/MyLifeOnlyObservers.cd b/docs/MyLifeOnlyObservers.cd new file mode 100644 index 000000000..8ba6bac27 --- /dev/null +++ b/docs/MyLifeOnlyObservers.cd @@ -0,0 +1,183 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person implements de.monticore.cd.ICDObservable{ + public String name; + public Date birthDate; + public String email; + protected ListobserverList; + public void addObserver(MyLife.IPersonObserver observer); + public void removeObserver(MyLife.IPersonObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetName(String ov); + protected void notifyObserversSetBirthDate(Date ov); + protected void notifyObserversSetEmail(String ov); + + } + public abstract class Asset implements de.monticore.cd.ICDObservable{ + public String assetId; + public Date createdDate; + public Priority priority; + protected ListobserverList; + public void addObserver(MyLife.IAssetObserver observer); + public void removeObserver(MyLife.IAssetObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetAssetId(String ov); + protected void notifyObserversSetCreatedDate(Date ov); + protected void notifyObserversSetPriority(Priority ov); + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person implements de.monticore.cd.ICDObservable{ + public String employeeId; + public double salary; + public Status employmentStatus; + public Listresponsibilities; + protected ListobserverList; + public void addObserver(MyLife.IEmployeeObserver observer); + public void removeObserver(MyLife.IEmployeeObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetEmployeeId(String ov); + protected void notifyObserversSetSalary(double ov); + protected void notifyObserversSetEmploymentStatus(Status ov); + protected void notifyObserversAddResponsibilities(int index,Priority newElem); + protected void notifyObserversRemoveResponsibilities(int index,Priority elem); + + } + public class Project extends Asset implements de.monticore.cd.ICDObservable{ + public String projectName; + public Date deadline; + public Listmilestones; + protected ListobserverList; + public void addObserver(MyLife.IProjectObserver observer); + public void removeObserver(MyLife.IProjectObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetProjectName(String ov); + protected void notifyObserversSetDeadline(Date ov); + protected void notifyObserversAddMilestones(int index,String newElem); + protected void notifyObserversRemoveMilestones(int index,String elem); + + } + public class Task extends Asset implements de.monticore.cd.ICDObservable{ + public String taskName; + public String description; + public Status taskStatus; + protected ListobserverList; + public void addObserver(MyLife.ITaskObserver observer); + public void removeObserver(MyLife.ITaskObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetTaskName(String ov); + protected void notifyObserversSetDescription(String ov); + protected void notifyObserversSetTaskStatus(Status ov); + + } + public class Team implements de.monticore.cd.ICDObservable{ + public String teamName; + public int teamSize; + public ListteamMembers; + protected ListobserverList; + public void addObserver(MyLife.ITeamObserver observer); + public void removeObserver(MyLife.ITeamObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetTeamName(String ov); + protected void notifyObserversSetTeamSize(int ov); + protected void notifyObserversAddTeamMembers(int index,String newElem); + protected void notifyObserversRemoveTeamMembers(int index,String elem); + + } + public class Department implements de.monticore.cd.ICDObservable{ + public String deptName; + public String location; + protected ListobserverList; + public void addObserver(MyLife.IDepartmentObserver observer); + public void removeObserver(MyLife.IDepartmentObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetDeptName(String ov); + protected void notifyObserversSetLocation(String ov); + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + public interface IPersonObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Person clazz); + public void notifyUpdateSetName(Person clazz,String ov); + public void notifyUpdateSetBirthDate(Person clazz,Date ov); + public void notifyUpdateSetEmail(Person clazz,String ov); + + } + public interface IAssetObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Asset clazz); + public void notifyUpdateSetAssetId(Asset clazz,String ov); + public void notifyUpdateSetCreatedDate(Asset clazz,Date ov); + public void notifyUpdateSetPriority(Asset clazz,Priority ov); + + } + public interface IEmployeeObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Employee clazz); + public void notifyUpdateSetEmployeeId(Employee clazz,String ov); + public void notifyUpdateSetSalary(Employee clazz,double ov); + public void notifyUpdateSetEmploymentStatus(Employee clazz,Status ov); + public void notifyUpdateAddResponsibilities(Employee clazz,int index,Priority newElem); + public void notifyUpdateRemoveResponsibilities(Employee clazz,int index,Priority elem); + + } + public interface IProjectObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Project clazz); + public void notifyUpdateSetProjectName(Project clazz,String ov); + public void notifyUpdateSetDeadline(Project clazz,Date ov); + public void notifyUpdateAddMilestones(Project clazz,int index,String newElem); + public void notifyUpdateRemoveMilestones(Project clazz,int index,String elem); + + } + public interface ITaskObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Task clazz); + public void notifyUpdateSetTaskName(Task clazz,String ov); + public void notifyUpdateSetDescription(Task clazz,String ov); + public void notifyUpdateSetTaskStatus(Task clazz,Status ov); + + } + public interface ITeamObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Team clazz); + public void notifyUpdateSetTeamName(Team clazz,String ov); + public void notifyUpdateSetTeamSize(Team clazz,int ov); + public void notifyUpdateAddTeamMembers(Team clazz,int index,String newElem); + public void notifyUpdateRemoveTeamMembers(Team clazz,int index,String elem); + + } + public interface IDepartmentObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Department clazz); + public void notifyUpdateSetDeptName(Department clazz,String ov); + public void notifyUpdateSetLocation(Department clazz,String ov); + + } + + } + +} diff --git a/docs/MyLifeOnlyObservers.svg b/docs/MyLifeOnlyObservers.svg new file mode 100644 index 000000000..3ade290fa --- /dev/null +++ b/docs/MyLifeOnlyObservers.svg @@ -0,0 +1,844 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + + String name; + + + Date birthDate; + + + String email; + + # List<MyLife.IPersonObserver>observerList; + + + + + + void addObserver(MyLife.IPersonObserver observer); + + + void removeObserver(MyLife.IPersonObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetName(String ov); + + # void notifyObserversSetBirthDate(Date ov); + + # void notifyObserversSetEmail(String ov); + + + + + + MyLife + + Β«abstractΒ» + Asset + + + + String assetId; + + + Date createdDate; + + + Priority priority; + + # List<MyLife.IAssetObserver>observerList; + + + + + + void addObserver(MyLife.IAssetObserver observer); + + + void removeObserver(MyLife.IAssetObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetAssetId(String ov); + + # void notifyObserversSetCreatedDate(Date ov); + + # void notifyObserversSetPriority(Priority ov); + + + + + + MyLife + + + Employee + + + + String employeeId; + + + double salary; + + + Status employmentStatus; + + + List<Priority>responsibilities; + + # List<MyLife.IEmployeeObserver>observerList; + + + + + + void addObserver(MyLife.IEmployeeObserver observer); + + + void removeObserver(MyLife.IEmployeeObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetEmployeeId(String ov); + + # void notifyObserversSetSalary(double ov); + + # void notifyObserversSetEmploymentStatus(Status ov); + + # void notifyObserversAddResponsibilities(int index,Priority newElem); + + # void notifyObserversRemoveResponsibilities(int index,Priority elem); + + + + + + MyLife + + + Project + + + + String projectName; + + + Date deadline; + + + List<String>milestones; + + # List<MyLife.IProjectObserver>observerList; + + + + + + void addObserver(MyLife.IProjectObserver observer); + + + void removeObserver(MyLife.IProjectObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetProjectName(String ov); + + # void notifyObserversSetDeadline(Date ov); + + # void notifyObserversAddMilestones(int index,String newElem); + + # void notifyObserversRemoveMilestones(int index,String elem); + + + + + + MyLife + + + Task + + + + String taskName; + + + String description; + + + Status taskStatus; + + # List<MyLife.ITaskObserver>observerList; + + + + + + void addObserver(MyLife.ITaskObserver observer); + + + void removeObserver(MyLife.ITaskObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetTaskName(String ov); + + # void notifyObserversSetDescription(String ov); + + # void notifyObserversSetTaskStatus(Status ov); + + + + + + MyLife + + + Team + + + + String teamName; + + + int teamSize; + + + List<String>teamMembers; + + # List<MyLife.ITeamObserver>observerList; + + + + + + void addObserver(MyLife.ITeamObserver observer); + + + void removeObserver(MyLife.ITeamObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetTeamName(String ov); + + # void notifyObserversSetTeamSize(int ov); + + # void notifyObserversAddTeamMembers(int index,String newElem); + + # void notifyObserversRemoveTeamMembers(int index,String elem); + + + + + + MyLife + + + Department + + + + String deptName; + + + String location; + + # List<MyLife.IDepartmentObserver>observerList; + + + + + + void addObserver(MyLife.IDepartmentObserver observer); + + + void removeObserver(MyLife.IDepartmentObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetDeptName(String ov); + + # void notifyObserversSetLocation(String ov); + + + + + + MyLife + + Β«interfaceΒ» + IPersonObserver + + + + + + void notifyUpdate(Person clazz); + + + void notifyUpdateSetName(Person clazz,String ov); + + + void notifyUpdateSetBirthDate(Person clazz,Date ov); + + + void notifyUpdateSetEmail(Person clazz,String ov); + + + + + + MyLife + + Β«interfaceΒ» + IAssetObserver + + + + + + void notifyUpdate(Asset clazz); + + + void notifyUpdateSetAssetId(Asset clazz,String ov); + + + void notifyUpdateSetCreatedDate(Asset clazz,Date ov); + + + void notifyUpdateSetPriority(Asset clazz,Priority ov); + + + + + + MyLife + + Β«interfaceΒ» + IEmployeeObserver + + + + + + void notifyUpdate(Employee clazz); + + + void notifyUpdateSetEmployeeId(Employee clazz,String ov); + + + void notifyUpdateSetSalary(Employee clazz,double ov); + + + void notifyUpdateSetEmploymentStatus(Employee clazz,Status ov); + + + void notifyUpdateAddResponsibilities(Employee clazz,int index,Priority newElem); + + + void notifyUpdateRemoveResponsibilities(Employee clazz,int index,Priority elem); + + + + + + MyLife + + Β«interfaceΒ» + IProjectObserver + + + + + + void notifyUpdate(Project clazz); + + + void notifyUpdateSetProjectName(Project clazz,String ov); + + + void notifyUpdateSetDeadline(Project clazz,Date ov); + + + void notifyUpdateAddMilestones(Project clazz,int index,String newElem); + + + void notifyUpdateRemoveMilestones(Project clazz,int index,String elem); + + + + + + MyLife + + Β«interfaceΒ» + ITaskObserver + + + + + + void notifyUpdate(Task clazz); + + + void notifyUpdateSetTaskName(Task clazz,String ov); + + + void notifyUpdateSetDescription(Task clazz,String ov); + + + void notifyUpdateSetTaskStatus(Task clazz,Status ov); + + + + + + MyLife + + Β«interfaceΒ» + ITeamObserver + + + + + + void notifyUpdate(Team clazz); + + + void notifyUpdateSetTeamName(Team clazz,String ov); + + + void notifyUpdateSetTeamSize(Team clazz,int ov); + + + void notifyUpdateAddTeamMembers(Team clazz,int index,String newElem); + + + void notifyUpdateRemoveTeamMembers(Team clazz,int index,String elem); + + + + + + MyLife + + Β«interfaceΒ» + IDepartmentObserver + + + + + + void notifyUpdate(Department clazz); + + + void notifyUpdateSetDeptName(Department clazz,String ov); + + + void notifyUpdateSetLocation(Department clazz,String ov); + + + + + + CD + + + diff --git a/docs/MyLifeOnlySetter.cd b/docs/MyLifeOnlySetter.cd new file mode 100644 index 000000000..d49793f87 --- /dev/null +++ b/docs/MyLifeOnlySetter.cd @@ -0,0 +1,103 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + protected String name; + protected Date birthDate; + protected String email; + public void setName(String name); + public void setBirthDate(Date birthDate); + public void setEmail(String email); + + } + public abstract class Asset { + protected String assetId; + protected Date createdDate; + protected Priority priority; + public void setAssetId(String assetId); + public void setCreatedDate(Date createdDate); + public void setPriority(Priority priority); + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + protected String employeeId; + protected double salary; + protected Status employmentStatus; + protected Listresponsibilities; + public void setEmployeeId(String employeeId); + public void setSalary(double salary); + public void setEmploymentStatus(Status employmentStatus); + public void addResponsibilities(int index,Priority responsibilities); + public Priority removeResponsibilities(int index); + + } + public class Project extends Asset { + protected String projectName; + protected Date deadline; + protected Listmilestones; + public void setProjectName(String projectName); + public void setDeadline(Date deadline); + public void addMilestones(int index,String milestones); + public String removeMilestones(int index); + + } + public class Task extends Asset { + protected String taskName; + protected String description; + protected Status taskStatus; + public void setTaskName(String taskName); + public void setDescription(String description); + public void setTaskStatus(Status taskStatus); + + } + public class Team { + protected String teamName; + protected int teamSize; + protected ListteamMembers; + public void setTeamName(String teamName); + public void setTeamSize(int teamSize); + public void addTeamMembers(int index,String teamMembers); + public String removeTeamMembers(int index); + + } + public class Department { + protected String deptName; + protected String location; + public void setDeptName(String deptName); + public void setLocation(String location); + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + + } + +} diff --git a/docs/MyLifeOnlySetter.svg b/docs/MyLifeOnlySetter.svg new file mode 100644 index 000000000..0e486e474 --- /dev/null +++ b/docs/MyLifeOnlySetter.svg @@ -0,0 +1,642 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + # String name; + + # Date birthDate; + + # String email; + + + + + + void setName(String name); + + + void setBirthDate(Date birthDate); + + + void setEmail(String email); + + + + + + MyLife + + Β«abstractΒ» + Asset + + + # String assetId; + + # Date createdDate; + + # Priority priority; + + + + + + void setAssetId(String assetId); + + + void setCreatedDate(Date createdDate); + + + void setPriority(Priority priority); + + + + + + MyLife + + + Employee + + + # String employeeId; + + # double salary; + + # Status employmentStatus; + + # List<Priority>responsibilities; + + + + + + void setEmployeeId(String employeeId); + + + void setSalary(double salary); + + + void setEmploymentStatus(Status employmentStatus); + + + void addResponsibilities(int index,Priority responsibilities); + + + Priority removeResponsibilities(int index); + + + + + + MyLife + + + Project + + + # String projectName; + + # Date deadline; + + # List<String>milestones; + + + + + + void setProjectName(String projectName); + + + void setDeadline(Date deadline); + + + void addMilestones(int index,String milestones); + + + String removeMilestones(int index); + + + + + + MyLife + + + Task + + + # String taskName; + + # String description; + + # Status taskStatus; + + + + + + void setTaskName(String taskName); + + + void setDescription(String description); + + + void setTaskStatus(Status taskStatus); + + + + + + MyLife + + + Team + + + # String teamName; + + # int teamSize; + + # List<String>teamMembers; + + + + + + void setTeamName(String teamName); + + + void setTeamSize(int teamSize); + + + void addTeamMembers(int index,String teamMembers); + + + String removeTeamMembers(int index); + + + + + + MyLife + + + Department + + + # String deptName; + + # String location; + + + + + + void setDeptName(String deptName); + + + void setLocation(String location); + + + + + + CD + + + diff --git a/docs/MyLifeOnlyVisitors.cd b/docs/MyLifeOnlyVisitors.cd new file mode 100644 index 000000000..be21090e7 --- /dev/null +++ b/docs/MyLifeOnlyVisitors.cd @@ -0,0 +1,182 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + protected String name; + protected Date birthDate; + protected String email; + public String getName(); + public Date getBirthDate(); + public String getEmail(); + public void accept(MyLife.IMyLifeVisitor visitor); + + } + public abstract class Asset { + protected String assetId; + protected Date createdDate; + protected Priority priority; + public String getAssetId(); + public Date getCreatedDate(); + public Priority getPriority(); + public void accept(MyLife.IMyLifeVisitor visitor); + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + protected String employeeId; + protected double salary; + protected Status employmentStatus; + protected Listresponsibilities; + public String getEmployeeId(); + public double getSalary(); + public Status getEmploymentStatus(); + public ListgetResponsibilities(); + public boolean containsResponsibilities(Object element); + public boolean containsAllResponsibilities(java.util.Collectioncollection); + public boolean isEmptyResponsibilities(); + public java.util.IteratoriteratorResponsibilities(); + public int sizeResponsibilities(); + public Priority []toArrayResponsibilities(Priority []array); + public Object []toArrayResponsibilities(); + public java.util.SpliteratorspliteratorResponsibilities(); + public java.util.stream.StreamstreamResponsibilities(); + public java.util.stream.StreamparallelStreamResponsibilities(); + public boolean equalsResponsibilities(Object o); + public int hashCodeResponsibilities(); + public Priority getResponsibilities(int index); + public int indexOfResponsibilities(Object element); + public int lastIndexOfResponsibilities(Object element); + public java.util.ListIteratorlistIteratorResponsibilities(); + public java.util.ListIteratorlistIteratorResponsibilities(int index); + public java.util.ListsubListResponsibilities(int start,int end); + public void accept(MyLife.IMyLifeVisitor visitor); + + } + public class Project extends Asset { + protected String projectName; + protected Date deadline; + protected Listmilestones; + public String getProjectName(); + public Date getDeadline(); + public ListgetMilestones(); + public boolean containsMilestones(Object element); + public boolean containsAllMilestones(java.util.Collectioncollection); + public boolean isEmptyMilestones(); + public java.util.IteratoriteratorMilestones(); + public int sizeMilestones(); + public String []toArrayMilestones(String []array); + public Object []toArrayMilestones(); + public java.util.SpliteratorspliteratorMilestones(); + public java.util.stream.StreamstreamMilestones(); + public java.util.stream.StreamparallelStreamMilestones(); + public boolean equalsMilestones(Object o); + public int hashCodeMilestones(); + public String getMilestones(int index); + public int indexOfMilestones(Object element); + public int lastIndexOfMilestones(Object element); + public java.util.ListIteratorlistIteratorMilestones(); + public java.util.ListIteratorlistIteratorMilestones(int index); + public java.util.ListsubListMilestones(int start,int end); + public void accept(MyLife.IMyLifeVisitor visitor); + + } + public class Task extends Asset { + protected String taskName; + protected String description; + protected Status taskStatus; + public String getTaskName(); + public String getDescription(); + public Status getTaskStatus(); + public void accept(MyLife.IMyLifeVisitor visitor); + + } + public class Team { + protected String teamName; + protected int teamSize; + protected ListteamMembers; + public String getTeamName(); + public int getTeamSize(); + public ListgetTeamMembers(); + public boolean containsTeamMembers(Object element); + public boolean containsAllTeamMembers(java.util.Collectioncollection); + public boolean isEmptyTeamMembers(); + public java.util.IteratoriteratorTeamMembers(); + public int sizeTeamMembers(); + public String []toArrayTeamMembers(String []array); + public Object []toArrayTeamMembers(); + public java.util.SpliteratorspliteratorTeamMembers(); + public java.util.stream.StreamstreamTeamMembers(); + public java.util.stream.StreamparallelStreamTeamMembers(); + public boolean equalsTeamMembers(Object o); + public int hashCodeTeamMembers(); + public String getTeamMembers(int index); + public int indexOfTeamMembers(Object element); + public int lastIndexOfTeamMembers(Object element); + public java.util.ListIteratorlistIteratorTeamMembers(); + public java.util.ListIteratorlistIteratorTeamMembers(int index); + public java.util.ListsubListTeamMembers(int start,int end); + public void accept(MyLife.IMyLifeVisitor visitor); + + } + public class Department { + protected String deptName; + protected String location; + public String getDeptName(); + public String getLocation(); + public void accept(MyLife.IMyLifeVisitor visitor); + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + public interface IMyLifeVisitor { + public abstract void visit(Person node); + public abstract void visit(Asset node); + public abstract void visit(Employee node); + public abstract void visit(Project node); + public abstract void visit(Task node); + public abstract void visit(Team node); + public abstract void visit(Department node); + + } + public class MyLifeVisitorImplementation implements IMyLifeVisitor { + protected CollectiontraversedElements; + public void visit(Person node); + public void visit(Asset node); + public void visit(Employee node); + public void visit(Project node); + public void visit(Task node); + public void visit(Team node); + public void visit(Department node); + + } + + } + +} diff --git a/docs/MyLifeOnlyVisitors.svg b/docs/MyLifeOnlyVisitors.svg new file mode 100644 index 000000000..f050bafd1 --- /dev/null +++ b/docs/MyLifeOnlyVisitors.svg @@ -0,0 +1,820 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + # String name; + + # Date birthDate; + + # String email; + + + + + + String getName(); + + + Date getBirthDate(); + + + String getEmail(); + + + void accept(MyLife.IMyLifeVisitor visitor); + + + + + + MyLife + + Β«abstractΒ» + Asset + + + # String assetId; + + # Date createdDate; + + # Priority priority; + + + + + + String getAssetId(); + + + Date getCreatedDate(); + + + Priority getPriority(); + + + void accept(MyLife.IMyLifeVisitor visitor); + + + + + + MyLife + + + Employee + + + # String employeeId; + + # double salary; + + # Status employmentStatus; + + # List<Priority>responsibilities; + + + + + + String getEmployeeId(); + + + double getSalary(); + + + Status getEmploymentStatus(); + + + List<Priority>getResponsibilities(); + + + boolean containsResponsibilities(Object element); + + + boolean containsAllResponsibilities(java.util.Collection<?>collection); + + + boolean isEmptyResponsibilities(); + + + java.util.Iterator<Priority>iteratorResponsibilities(); + + + int sizeResponsibilities(); + + + Priority []toArrayResponsibilities(Priority []array); + + + Object []toArrayResponsibilities(); + + + java.util.Spliterator<Priority>spliteratorResponsibilities(); + + + java.util.stream.Stream<Priority>streamResponsibilities(); + + + java.util.stream.Stream<Priority>parallelStreamResponsibilities(); + + + boolean equalsResponsibilities(Object o); + + + int hashCodeResponsibilities(); + + + Priority getResponsibilities(int index); + + + int indexOfResponsibilities(Object element); + + + int lastIndexOfResponsibilities(Object element); + + + java.util.ListIterator<Priority>listIteratorResponsibilities(); + + + java.util.ListIterator<Priority>listIteratorResponsibilities(int index); + + + java.util.List<Priority>subListResponsibilities(int start,int end); + + + void accept(MyLife.IMyLifeVisitor visitor); + + + + + + MyLife + + + Project + + + # String projectName; + + # Date deadline; + + # List<String>milestones; + + + + + + String getProjectName(); + + + Date getDeadline(); + + + List<String>getMilestones(); + + + boolean containsMilestones(Object element); + + + boolean containsAllMilestones(java.util.Collection<?>collection); + + + boolean isEmptyMilestones(); + + + java.util.Iterator<String>iteratorMilestones(); + + + int sizeMilestones(); + + + String []toArrayMilestones(String []array); + + + Object []toArrayMilestones(); + + + java.util.Spliterator<String>spliteratorMilestones(); + + + java.util.stream.Stream<String>streamMilestones(); + + + java.util.stream.Stream<String>parallelStreamMilestones(); + + + boolean equalsMilestones(Object o); + + + int hashCodeMilestones(); + + + String getMilestones(int index); + + + int indexOfMilestones(Object element); + + + int lastIndexOfMilestones(Object element); + + + java.util.ListIterator<String>listIteratorMilestones(); + + + java.util.ListIterator<String>listIteratorMilestones(int index); + + + java.util.List<String>subListMilestones(int start,int end); + + + void accept(MyLife.IMyLifeVisitor visitor); + + + + + + MyLife + + + Task + + + # String taskName; + + # String description; + + # Status taskStatus; + + + + + + String getTaskName(); + + + String getDescription(); + + + Status getTaskStatus(); + + + void accept(MyLife.IMyLifeVisitor visitor); + + + + + + MyLife + + + Team + + + # String teamName; + + # int teamSize; + + # List<String>teamMembers; + + + + + + String getTeamName(); + + + int getTeamSize(); + + + List<String>getTeamMembers(); + + + boolean containsTeamMembers(Object element); + + + boolean containsAllTeamMembers(java.util.Collection<?>collection); + + + boolean isEmptyTeamMembers(); + + + java.util.Iterator<String>iteratorTeamMembers(); + + + int sizeTeamMembers(); + + + String []toArrayTeamMembers(String []array); + + + Object []toArrayTeamMembers(); + + + java.util.Spliterator<String>spliteratorTeamMembers(); + + + java.util.stream.Stream<String>streamTeamMembers(); + + + java.util.stream.Stream<String>parallelStreamTeamMembers(); + + + boolean equalsTeamMembers(Object o); + + + int hashCodeTeamMembers(); + + + String getTeamMembers(int index); + + + int indexOfTeamMembers(Object element); + + + int lastIndexOfTeamMembers(Object element); + + + java.util.ListIterator<String>listIteratorTeamMembers(); + + + java.util.ListIterator<String>listIteratorTeamMembers(int index); + + + java.util.List<String>subListTeamMembers(int start,int end); + + + void accept(MyLife.IMyLifeVisitor visitor); + + + + + + MyLife + + + Department + + + # String deptName; + + # String location; + + + + + + String getDeptName(); + + + String getLocation(); + + + void accept(MyLife.IMyLifeVisitor visitor); + + + + + + MyLife + + Β«interfaceΒ» + IMyLifeVisitor + + + + + + abstract void visit(Person node); + + + abstract void visit(Asset node); + + + abstract void visit(Employee node); + + + abstract void visit(Project node); + + + abstract void visit(Task node); + + + abstract void visit(Team node); + + + abstract void visit(Department node); + + + + + + MyLife + + + MyLifeVisitorImplementation + + + # Collection<Object>traversedElements; + + + + + + void visit(Person node); + + + void visit(Asset node); + + + void visit(Employee node); + + + void visit(Project node); + + + void visit(Task node); + + + void visit(Team node); + + + void visit(Department node); + + + + + + CD + + + diff --git a/docs/MyLifeOnlyWithAbstractMethodSignatures.cd b/docs/MyLifeOnlyWithAbstractMethodSignatures.cd new file mode 100644 index 000000000..39fae065b --- /dev/null +++ b/docs/MyLifeOnlyWithAbstractMethodSignatures.cd @@ -0,0 +1,79 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.lang.String; +import java.util.List; +import java.util.Date; +import java.util.*; +public classdiagram MyLife { + package MyLife { + // ===== Enums ===== + public enum Status { + ACTIVE,INACTIVE,PAUSED; + + } + public enum Priority { + LOW,MEDIUM,HIGH,CRITICAL; + + } + public enum Role { + MANAGER,DEVELOPER,DESIGNER,ANALYST; + + } + // ===== Abstract Base Classes ===== + public abstract class Person { + public String name; + public Date birthDate; + public String email; + + } + public abstract class Asset { + public String assetId; + public Date createdDate; + public Priority priority; + + } + // ===== Concrete Classes (with inheritance) ===== + public class Employee extends Person { + public String employeeId; + public double salary; + public Status employmentStatus; + public Listresponsibilities; + + } + public class Project extends Asset { + public String projectName; + public Date deadline; + public Listmilestones; + + } + public class Task extends Asset { + public String taskName; + public String description; + public Status taskStatus; + + } + public class Team { + public String teamName; + public int teamSize; + public ListteamMembers; + + } + public class Department { + public String deptName; + public String location; + + } + // ===== Associations (Class-to-Class) ===== + public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; + public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; + public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; + public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; + public association public [1..*]Project(includes)--(part_of)Task[0..*]public; + public association public [1..*]Department(organizes)--(team)Team[0..*]public; + public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; + // ===== Compositions ===== + public composition public [1]Project(project)--(task)Task [1..*]public; + public composition public [1]Department(department)--(team)Team [1..*]public; + + } + +} diff --git a/docs/MyLifeOnlyWithAbstractMethodSignatures.svg b/docs/MyLifeOnlyWithAbstractMethodSignatures.svg new file mode 100644 index 000000000..9ec00d981 --- /dev/null +++ b/docs/MyLifeOnlyWithAbstractMethodSignatures.svg @@ -0,0 +1,587 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + works_in + 1..* + + + + + + + + works_in + + + + + + + has_members + 0..* + + + + + + + + has_members + + + + + + + + + + + + + manages + 1..* + + + + + + + + manages + + + + + + + assigned_to + 0..* + + + + + + + + assigned_to + + + + + + + + + + + + + works_on + 0..* + + + + + + + + works_on + + + + + + + lead_by + 1 + + + + + + + + lead_by + + + + + + + + + + + + + contains + 1..* + + + + + + + + contains + + + + + + + belongs_to + 0..* + + + + + + + + belongs_to + + + + + + + + + + + + + includes + 1..* + + + + + + + + includes + + + + + + + part_of + 0..* + + + + + + + + part_of + + + + + + + + + + + + + organizes + 1..* + + + + + + + + organizes + + + + + + + team + 0..* + + + + + + + + team + + + + + + + + + + + + + reports_to + 1..* + + + + + + + + reports_to + + + + + + + role + 0..* + + + + + + + + role + + + + + + + + + + + + + project + + + + + + + + + project + + + + + + + task + 1..* + + + + + + + + task + + + + + + + + + + + + + department + + + + + + + + + department + + + + + + + team + 1..* + + + + + + + + team + + + + + + MyLife + + Β«enumΒ» + Status + + + ACTIVE + INACTIVE + PAUSED + + + + + + + + + MyLife + + Β«enumΒ» + Priority + + + LOW + MEDIUM + HIGH + CRITICAL + + + + + + + + + MyLife + + Β«enumΒ» + Role + + + MANAGER + DEVELOPER + DESIGNER + ANALYST + + + + + + + + + MyLife + + Β«abstractΒ» + Person + + + + String name; + + + Date birthDate; + + + String email; + + + + + + + + MyLife + + Β«abstractΒ» + Asset + + + + String assetId; + + + Date createdDate; + + + Priority priority; + + + + + + + + MyLife + + + Employee + + + + String employeeId; + + + double salary; + + + Status employmentStatus; + + + List<Priority>responsibilities; + + + + + + + + MyLife + + + Project + + + + String projectName; + + + Date deadline; + + + List<String>milestones; + + + + + + + + MyLife + + + Task + + + + String taskName; + + + String description; + + + Status taskStatus; + + + + + + + + MyLife + + + Team + + + + String teamName; + + + int teamSize; + + + List<String>teamMembers; + + + + + + + + MyLife + + + Department + + + + String deptName; + + + String location; + + + + + + + + CD + + + From 78bc741c75ed8f2a7bf237e2d5163cb02760553a Mon Sep 17 00:00:00 2001 From: Hendrik7889 <44064629+Hendrik7889@users.noreply.github.com> Date: Sat, 6 Jun 2026 19:54:05 +0200 Subject: [PATCH 04/14] add Decorator description to the GettingStarted.md --- .gitignore | 1 + docs/GettingStarted.md | 387 +++++--- docs/MyLife.cd | 27 - docs/MyLife.svg | 61 -- docs/MyLifeNoDecorators.cd | 79 -- docs/MyLifeNoDecorators.svg | 587 ------------ docs/MyLifeOnlyBuilders.cd | 198 ---- docs/MyLifeOnlyBuilders.svg | 860 ------------------ docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd | 82 -- .../MyLifeOnlyDefaultsForCardinalityAttrs.svg | 587 ------------ docs/MyLifeOnlyGetter.cd | 154 ---- docs/MyLifeOnlyGetter.svg | 744 --------------- docs/MyLifeOnlyNavigableSetter.cd | 103 --- docs/MyLifeOnlyNavigableSetter.svg | 642 ------------- docs/MyLifeOnlyObservers.cd | 183 ---- docs/MyLifeOnlyObservers.svg | 844 ----------------- docs/MyLifeOnlySetter.cd | 103 --- docs/MyLifeOnlySetter.svg | 642 ------------- docs/MyLifeOnlyVisitors.cd | 182 ---- docs/MyLifeOnlyVisitors.svg | 820 ----------------- .../MyLifeOnlyWithAbstractMethodSignatures.cd | 79 -- ...MyLifeOnlyWithAbstractMethodSignatures.svg | 587 ------------ docs/myOrganizer/cds/MyOrganizer.cd | 30 + .../cds/MyOrganizerNoDecorators.cd | 38 + .../cds/MyOrganizerOnlyBuilders.cd | 87 ++ ...rganizerOnlyDefaultsForCardinalityAttrs.cd | 39 + docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd | 58 ++ .../cds/MyOrganizerOnlyNavigableSetter.cd | 50 + .../cds/MyOrganizerOnlyObservers.cd | 88 ++ docs/myOrganizer/cds/MyOrganizerOnlySetter.cd | 47 + .../cds/MyOrganizerOnlyVisitors.cd | 77 ++ ...ganizerOnlyWithAbstractMethodSignatures.cd | 38 + docs/myOrganizer/img/MyOrganizer.svg | 212 +++++ .../img/MyOrganizerNoDecorators.svg | 218 +++++ .../img/MyOrganizerOnlyBuilders.svg | 336 +++++++ ...ganizerOnlyDefaultsForCardinalityAttrs.svg | 218 +++++ .../myOrganizer/img/MyOrganizerOnlyGetter.svg | 259 ++++++ .../img/MyOrganizerOnlyNavigableSetter.svg | 243 +++++ .../img/MyOrganizerOnlyObservers.svg | 344 +++++++ .../myOrganizer/img/MyOrganizerOnlySetter.svg | 237 +++++ .../img/MyOrganizerOnlyVisitors.svg | 317 +++++++ ...anizerOnlyWithAbstractMethodSignatures.svg | 218 +++++ 42 files changed, 3395 insertions(+), 7711 deletions(-) delete mode 100644 docs/MyLife.cd delete mode 100644 docs/MyLife.svg delete mode 100644 docs/MyLifeNoDecorators.cd delete mode 100644 docs/MyLifeNoDecorators.svg delete mode 100644 docs/MyLifeOnlyBuilders.cd delete mode 100644 docs/MyLifeOnlyBuilders.svg delete mode 100644 docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd delete mode 100644 docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg delete mode 100644 docs/MyLifeOnlyGetter.cd delete mode 100644 docs/MyLifeOnlyGetter.svg delete mode 100644 docs/MyLifeOnlyNavigableSetter.cd delete mode 100644 docs/MyLifeOnlyNavigableSetter.svg delete mode 100644 docs/MyLifeOnlyObservers.cd delete mode 100644 docs/MyLifeOnlyObservers.svg delete mode 100644 docs/MyLifeOnlySetter.cd delete mode 100644 docs/MyLifeOnlySetter.svg delete mode 100644 docs/MyLifeOnlyVisitors.cd delete mode 100644 docs/MyLifeOnlyVisitors.svg delete mode 100644 docs/MyLifeOnlyWithAbstractMethodSignatures.cd delete mode 100644 docs/MyLifeOnlyWithAbstractMethodSignatures.svg create mode 100644 docs/myOrganizer/cds/MyOrganizer.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerNoDecorators.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlySetter.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd create mode 100644 docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd create mode 100644 docs/myOrganizer/img/MyOrganizer.svg create mode 100644 docs/myOrganizer/img/MyOrganizerNoDecorators.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlyBuilders.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlyDefaultsForCardinalityAttrs.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlyGetter.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlyNavigableSetter.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlyObservers.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlySetter.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlyVisitors.svg create mode 100644 docs/myOrganizer/img/MyOrganizerOnlyWithAbstractMethodSignatures.svg diff --git a/.gitignore b/.gitignore index 55075ebd7..f251523c8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ gradlew gradlew.bat ~$* .intellijPlatform/ +docs_wd # AI .claude/** \ No newline at end of file diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 3bf1dbf63..00a8d568e 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -102,94 +102,71 @@ extended with the addition of decorators. These decorators dictate what artifact are generated from the class diagram, or which should not be generated at all. ```cd4code -package corp; import java.util.Date; -classdiagram MyCompany { +classdiagram MyOrganizer { - enum CorpKind { SOLE_PROPRIETOR, S_CORP, C_CORP, B_CORP, CLOSE_CORP, NON_PROFIT; } - abstract class Entity; - - package people { - class Person extends Entity { - Date birthday; - List nickNames; - -> Address [*] {ordered}; - } - class Address { - String city; - String street; - int number; - } + enum Status { PROCESSING, DONE, OPEN; } + + abstract class Asset { + void process(); } - - class Company extends Entity { - CorpKind kind; + + class Task extends Asset { + String taskName; + Status taskStatus; + void process(); } - class Employee extends people.Person { - int salary; + + class Project extends Asset { + public String projectName; + double budget; + void process(); } - class Share { - int value; + + class Day { + Date date; } - - association [1..*] Company (employer) <-> Employee [*]; - composition [1] Company <- Share [*]; - association shareholding [1] Entity (shareholder) -- (owns) Share [*]; + association [1] Day (day) -> (tasks) Task [1]; + association [*] Task (tasks) <-> (project) Project [1]; } ``` -
Listing 2.1: The MyCompany class diagram
+
Listing 2.1: The MyOrganizer class diagram
As usual in model-based software engineering, the core of the file is the diagram definition itself. It begins with the `classdiagram` keyword, followed by the name of the diagram, -which must match the filename. In our example, the diagram is named `MyCompany` and +which must match the filename. In our example, the diagram is named `MyOrganizer` and its body is enclosed in curly braces `{ }`. Class diagrams can have a package declaration and import statements to integrate external types. If a class diagram defines a package, the package declaration must be the first statement in the file and takes the form `package` *QualifiedName*, where `package` is a keyword and -*QualifiedName* is an arbitrary namespace (e.g., `corp`). -The optional imports follow the package definition. Every import is of the -form `import` *QualifiedName*. For instance, the `MyCompany` class diagram +*QualifiedName* is an arbitrary namespace. +Every import is of the form `import` *QualifiedName*. For instance, the `MyOrganizer` class diagram uses `import java.util.Date;` to make the standard Java `Date` class available within the model. -The package `corp` also serves as the default namespace for all generated Java classes -unless specified otherwise. Inside the class diagram, various object-oriented constructs can be defined, such as enumerations, -classes, and interfaces. The `MyCompany` diagram introduces the enumeration `CorpKind` using -the `enum` keyword, defining several constants like `SOLE_PROPRIETOR` and `NON_PROFIT`. -It also defines several classes, such as `Entity`, `Person`, and `Company`. The `abstract` -keyword can be applied to classes, as seen with `abstract class Entity;`, instructing the -generator that this class serves as a base concept and cannot be instantiated directly. -Furthermore, the `extends` keyword is used to establish inheritance; for example, -`Company` extends `Entity`, and `Employee` extends `people.Person`. - -To further structure the model, class diagrams can contain nested packages. The `MyCompany` -diagram uses `package people` to group the `Person` and `Address` classes logically. -When referencing classes from other nested packages, their names must be qualified, -which is why `Employee` extends `people.Person`. +classes, interfaces, and their relationships. The `MyOrganizer` diagram introduces the enumeration `Status` using +the `enum` keyword, defining the constants `PROCESSING`, `DONE`, and `OPEN`. +It also defines several classes, such as `Asset`, `Task`, `Project`, and `Day`. The `abstract` +keyword can be applied to classes, as seen with `abstract class Asset;`. +Furthermore, the `extends` keyword is used to establish inheritance. In our example, +`Task` extends `Asset`, and `Project` extends `Asset`. Equaly, interfaces can be defined +as well, using the `interface` keyword, and classes can implement interfaces using the `implements` keyword. Classes typically contain attributes, which consist of a type and a name. The CD4Code -generator supports standard Java primitive types (like `int number` in `Address`), -imported external types (like `Date birthday`), and predefined generic types -(like `List nickNames`). - -Finally, the class diagram defines how these entities relate to one another using -associations and compositions. These relationships can be defined standalone at -the bottom of the file or inline within a class. For example, `Person` contains -an inline directed association `-> Address [*] {ordered};`. Standalone -relationships use keywords like `association` or `composition`, followed by -cardinalities (e.g., `[1]`, `[1..*]`, `[*]`), the participating classes, -and navigation arrows (`<->` for bidirectional, `<-` for directional, -or `--` for unspecified). Relationships can also be named (e.g., `shareholding`) -and can specify role names in parentheses to clarify the relationship's context, -such as `Company (employer) <-> Employee [*]`. Additional constraints or tags, -such as `{ordered}`, can be appended to instruct the generator to maintain a -specific sorting behavior in the resulting Java collections. +generator supports standard Java primitive types (like `double budget;`) , imported external types (like `Date date`), +and custom types like enums (`Status taskStatus`). Classes and interfaces can also define methods, such as `void process();`. -It is possible to have multiple CD files. The CD4Code generator can process all -files in the specified directories and generate Java code for all class diagrams. +Finally, the class diagram defines how these entities relate to one another using associations and compositions. +While associations define relationships between two entities that simply know about each other, +compositions define a strong ownership relationship between two entities. +Standalone relationships use keywords like `association` or `composition`, followed by +cardinalities (e.g., `[1]`, `[1..*]`, `[*]`), the participating classes, +and navigation arrows (`<->` for bidirectional, `->` for directional, +or `--` for unspecified). Relationships can also specify role names in parentheses to clarify the relationship's context, +such as `(project)` and `(tasks)`. ### Default Configuration: CD2Poj By default, the [CD2Pojo.ftl](../cdlang/src/main/resources/cd2java/init/CD2Pojo.ftl) template @@ -218,9 +195,8 @@ In the default configuration, 🟨 means the decorator is not applied unless enabled. This means by default that the CD4Code generator will generate getters and setters for all attributes. -Furthermore, it will initialize the cardinality of all optional attributes with an empty default value -and the class `People` is initated with an empty list. Finally, the bidirectional associations between -`Company` and `Employee` will be navigable in both directions, meaning that the generated setter methods +Furthermore, it will initialize the cardinality of all optional attributes with an empty default value. Finally, the bidirectional associations between +`Project` and `Task` will be navigable in both directions, meaning that the generated setter methods will also set the opposite side of the association by default. ### Configuring the CD4Code Generator @@ -235,8 +211,8 @@ Configuration can be applied at two different levels: 1. **Element-Level Configuration (Tagging):** You can target specific elements inside your class diagram (such as a specific class, enum, or attribute) to explicitly enable or disable a decorator. This uses a targeting syntax of `.:`. For example, targeting - `MyCompany.Address:noSetter` will prevent the generator from creating setter methods specifically for - the `Address` class. + `MyOrganizer.Day:noSetter` will prevent the generator from creating setter methods specifically for + the `Day` class. 2. **Global-Level Configuration (Templates):** If you need to fundamentally change the default behavior or apply your own custom decorators across the entire build, you can supply a custom configuration template (e.g., a custom `.ftl` file) to replace the default `CD2Pojo` template. @@ -250,18 +226,18 @@ your Gradle build script, or directly through the Java API. Select your environm When running the CD4Code generator from the command line, you can pass element-level tags using the `-cliconfig` parameter. Multiple configurations can be applied by repeating the argument. - For example, to disable getters and setters specifically for the `Address` class inside the `MyCompany` + For example, to disable getters and setters specifically for the `Day` class inside the `MyOrganizer` diagram, use the following command: ```shell - java -jar MCCD.jar -i src/MyCompany.cd -cliconfig "MyCompany.Address:noGetter" -cliconfig "MyCompany.Address:noSetter" + java -jar MCCD.jar -i src/MyOrganizer.cd -cliconfig "MyOrganizer.Day:noGetter" -cliconfig "MyOrganizer.Day:noSetter" ``` To apply a global configuration template, use the `-ct` (config template) argument to specify the template name, and `-fp` (file path) to specify the directory where the custom `.ftl` file is located: ```shell - java -jar MCCD.jar -i src/MyCompany.cd -ct CD2OwnDecorator -fp src/main/configTemplate + java -jar MCCD.jar -i src/MyOrganizer.cd -ct CD2OwnDecorator -fp src/main/configTemplate ``` === "Gradle" @@ -271,9 +247,9 @@ your Gradle build script, or directly through the Java API. Select your environm ```groovy // build.gradle tasks.named("generateClassDiagrams") { - // Element-level configuration targeting the Address class - options.add("MyCompany.Address:noGetter") - options.add("MyCompany.Address:noSetter") + // Element-level configuration targeting the Day class + options.add("MyOrganizer.Day:noGetter") + options.add("MyOrganizer.Day:noSetter") // Global-level configuration: Change the config template used by the generator // getConfigTemplate().set("CD2OwnDecorator") @@ -287,69 +263,180 @@ your Gradle build script, or directly through the Java API. Select your environm } ``` +## Decorators +At the very start of the CD4Code generator, the generator parses the class diagram DSL into the *CD4C Abstract Syntax Tree (AST)* +which represents the class diagram as an object tree. +In a first step, the CD4Code generator uses the mandatory CopyDecorator to unify the *CD4C AST*. +It copies the parsed AST and unifies it by adding a package if no package exists. Furthermore, it adds the +attributes defined in the association and compositions to the respective classes. This means for cardinality `[*]` the +attribute is added as a Set and for cardinality `[1]` it is added as a single field, and for cardinality `[1..*]` it +is added as an Optional. +All unset visibilities of attributes, classes, interfaces, and enums are set to public. +Based on this unified AST, the CD4Code generator applies the other decorators which can be selected individually by the user. +In Figure 4.1 we can see the original class diagram and in Figure 4.2 the generated code. + +![Figure 4.1 The original class diagram](../myOrganizer/img/MyOrganizer.svg) +
Figure 4.1 The original class diagram
+ +![Figure 4.2 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.2 The original class diagram after applying the CopyDecorator
+ +=== "GetterDecorator" + The GetterDecorator adds getter methods to all attributes of the class diagram. + + ![Figure 4.3 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.13 The original class diagram
+ + ![Figure 4.4 The original class diagram after applying the GetterDecorator](../myOrganizer/img/MyOrganizerOnlyGetter.svg) +
Figure 4.4 The original class diagram after applying the GetterDecorator
+ +=== "SetterDecorator" + The SetterDecorator adds setter methods to all attributes of the class diagram. + + ![Figure 4.5 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.5 The original class diagram
+ + ![Figure 4.6 The original class diagram after applying the SetterDecorator](../myOrganizer/img/MyOrganizerOnlySetter.svg) +
Figure 4.6 The original class diagram after applying the SetterDecorator
+ +=== "CardinalitiesDefaultDecorator" + The CardinalitiesDefaultDecorator initiates Lists, Sets, and Optional attributes of the class diagram with an empty List, empty Set, or an empty Optional respectively. As the CopyDecorator always runs as the first Decorator and adds the attributes defined in the associations and compositions to the respective classes, the CardinalitiesDefaultDecorator also adds default values to these attributes. + + As cardinality is not specified in the class diagram, the CardinalitiesDefaultDecorator instead injects the initialization via a template hook. This template contains the specific java code which is then in the generation step checked and applied. + +=== "NavigableSetterDecorator" + The NavigableSetterDecorator adds setter methods to all navigable associations of the class diagram. + + ![Figure 4.9 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.9 The original class diagram
+ + ![Figure 4.10 The original class diagram after applying the NavigableSetterDecorator](../myOrganizer/img/MyOrganizerOnlyNavigableSetter.svg) +
Figure 4.10 The original class diagram after applying the NavigableSetterDecorator
+ +=== "AbstractMethodDecorator" + The AbstractMethodDecorator adds abstract methods to all methods of the class diagram. + + ![Figure 4.11 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.11 The original class diagram
+ + ![Figure 4.12 The original class diagram after applying the AbstractMethodDecorator](../myOrganizer/img/MyOrganizerOnlyWithAbstractMethodSignatures.svg) +
Figure 4.12 The original class diagram after applying the AbstractMethodDecorator
+ +=== "BuilderDecorator" + The BuilderDecorator adds a builder class to all classes of the class diagram. + + ![Figure 4.13 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.13 The original class diagram
+ + ![Figure 4.14 The original class diagram after applying the BuilderDecorator](../myOrganizer/img/MyOrganizerOnlyBuilders.svg) +
Figure 4.14 The original class diagram after applying the BuilderDecorator
+ +=== "ObserverDecorator" + The ObserverDecorator adds an observable interface to all classes of the class diagram. + + ![Figure 4.15 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.15 The original class diagram
+ + ![Figure 4.16 The original class diagram after applying the ObserverDecorator](../myOrganizer/img/MyOrganizerOnlyObservers.svg) +
Figure 4.16 The original class diagram after applying the ObserverDecorator
+ +=== "VisitorDecorator" + The VisitorDecorator adds a visitor interface to all classes of the class diagram. + + ![Figure 4.17 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 4.17 The original class diagram
+ + ![Figure 4.18 The original class diagram after applying the VisitorDecorator](../myOrganizer/img/MyOrganizerOnlyVisitors.svg) +
Figure 4.18 The original class diagram after applying the VisitorDecorator
+ + +Because some Decorators are dependent on other Decorators, running prior to them, Decorators all implement the +interface `IDecorator` which has the method `getDependencies()` that returns a list of Decorators that must +be run before the respective Decorator. For example, the VisitorDecorator depends on the GetterDecorator, +so the `getDependencies()` method returns `Collections.singletonList(GetterDecorator.class)`. Therefore, the +CD4Code generator checks the dependencies of the selected Decorators and runs them in the correct order. +If there is a circular dependency, the CD4Code generator throws an error and does not generate any code. + +```java +/** Extend {@link AbstractDecorator} for shared */ +public interface IDecorator extends IVisitor { + + /** + * Add your decorator-visitor to the given traverser + * + * @param traverser the traverser + */ + void addToTraverser(CD4CodeTraverser traverser); + + void init(DecoratorData util, Optional glexOpt); + + /** @return the list of decorators which MUST traverse the AST before */ + @SuppressWarnings("rawtypes") + default Iterable> getMustRunAfter() { + return Collections.singletonList(ICreator.class); + } + +} +``` + + ## Running the CD4Code Generator The execution of the CD4Code Generator follows a structured pipeline. -First parsing and validating the model, then managing its symbols, and finally transforming the diagram +First parsing and validating the model, then managing its symbols, and finally transforming the diagram into executable Java source code. ### 1. Loading, CoCo-Checking, and Symbol Table Creation -The first phase of execution focuses on frontend processing. The generator loads the .cd file, parses its -contents, creates an internal symbol table to resolve types, and runs Context Conditions (CoCos) to +The first phase of execution focuses on frontend processing. The generator loads the .cd file, parses its +contents, creates an internal symbol table to resolve types, and runs Context Conditions (CoCos) to ensure the diagram adheres to all semantic rules of the language. === "CLI" - To parse and validate a class diagram model without generating any code artifacts, pass the input file - using the `-i` flag to specify the input file path. By default, basic validation occurs, but you can - explicitly enforce full CoCo checks or enable Java type resolution. - + To parse and validate a class diagram model without generating any code artifacts, pass the input file using the `-i` flag to specify the input file path. By default, basic validation occurs, but you can explicitly enforce full CoCo checks or enable Java type resolution. + ```shell # Basic parse, symbol table creation, and check - java -jar MCCD.jar -i src/MyCompany.cd + java -jar MCCD.jar -i src/MyOrganizer.cd # Explicitly check all CD4C Context Conditions (CoCos) - java -jar MCCD.jar -i src/MyCompany.cd --checkcocos + java -jar MCCD.jar -i src/MyOrganizer.cd --checkcocos # Enable resolution of standard Java classes (e.g., java.util.List) within the model - java -jar MCCD.jar -i src/MyCompany.cd --class2mc + java -jar MCCD.jar -i src/MyOrganizer.cd --class2mc ``` === "Gradle" - In a standard Gradle setup, the plugin automatically configures these phases as part of its default task - execution pipeline. However, you can control CoCo behavior and type resolution directly within the task - configuration block. + In a standard Gradle setup, the plugin automatically configures these phases as part of its default task execution pipeline. However, you can control CoCo behavior and type resolution directly within the task configuration block. + ```groovy // build.gradle tasks.named("generateClassDiagrams") { // Enables resolving standard Java classes used inside the CD diagram getClass2MC().set(true) - + // Controls whether CoCo checks are executed (enabled by default) getCoCos().set(true) } ``` ### 2. Storing and Exporting Symbols -In a large-scale project, comprehensibility suffers when a single file contains all artifacts of our class -diagram. To address this issue, the CD4Code Generator can serialize its symbol table into a standalone -symbol file, which can then be exported or loaded as a dependency by other models. +In a large-scale project, comprehensibility suffers when a single file contains all artifacts of our class +diagram. To address this issue, the CD4Code Generator can serialize its symbol table into a standalone +symbol file, which can then be exported or loaded as a dependency by other models. === "CLI" - Use the `-s` or `--symboltable` flag to specify where the serialized symbol table file should be saved. - If your diagram depends on external symbols, use the -path flag to point to the directory containing - those symbol files. + Use the `-s` or `--symboltable` flag to specify where the serialized symbol table file should be saved. If your diagram depends on external symbols, use the -path flag to point to the directory containing those symbol files. + ```shell # Export the symbol table to a specific file - java -jar MCCD.jar -i src/MyCompany.cd -s out/symbols/MyCompany.cdsym - + java -jar MCCD.jar -i src/MyOrganizer.cd -s out/symbols/MyOrganizer.cdsym + # Load external dependencies/symbols while processing a diagram - java -jar MCCD.jar -i src/MyCompany.cd -path dependencies/symbols/ + java -jar MCCD.jar -i src/MyOrganizer.cd -path dependencies/symbols/ ``` === "Gradle" - The Gradle plugin manages symbol storage and tracking automatically, storing original and decorated - symbols in separate build directories. You can customize these locations if your build pipeline - requires a non-standard layout. - + The Gradle plugin manages symbol storage and tracking automatically, storing original and decorated symbols in separate build directories. You can customize these locations if your build pipeline requires a non-standard layout. + ```groovy // build.gradle tasks.named("generateClassDiagrams") { @@ -366,35 +453,32 @@ Once the model is fully validated and its symbols are resolved, the generator ca the decorators and generate the actual Java source files. === "CLI" - To trigger code generation, you must explicitly include the `--gen` flag. You can combine this with the - `-o` flag to specify the target directory for the generated code, and `--fieldfromrole` to control - how associations are translated into actual class fields. + To trigger code generation, you must explicitly include the `--gen` flag. You can combine this with the `-o` flag to specify the target directory for the generated code, and `--fieldfromrole` to control how associations are translated into actual class fields. + ``` # Generate Java files into a dedicated output directory - java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources - + java -jar MCCD.jar -i src/MyOrganizer.cd --gen -o out/generated-sources + # Generate code while explicitly mapping navigable association roles to Java fields - java -jar MCCD.jar -i src/MyCompany.cd --gen -o out/generated-sources --fieldfromrole navigable + java -jar MCCD.jar -i src/MyOrganizer.cd --gen -o out/generated-sources --fieldfromrole navigable ``` - If your class diagram contains associations (e.g., `association [1..*] Company (employer) <-> Employee [*]`), + If your class diagram contains associations (e.g., `association [*] Task (tasks) <-> (project) Project [1];`), the basic `--gen` command will not automatically generate the corresponding Java fields to link these objects. Instead, you must explicitly tell the generator to map these association roles to fields using the `--fieldfromrole` flag. - In our example, the `Company` class has a role named `employer` in its association with `Employee`. - This means the generator will create an `employer` field inside the generated `Employee` Java class to represent + In our example, the `Project` class has a role named `project` in its association with `Task`. + This means the generator will create an `project` field inside the generated `Task` Java class to represent the relationship. To generate these fields, use the following command: ```shell - java -jar MCCD.jar -i src/MyCompany.cd -o out --gen --fieldfromrole navigable + java -jar MCCD.jar -i src/MyOrganizer.cd -o out --gen --fieldfromrole navigable ``` === "Gradle" - Code generation is fully integrated into the standard Gradle lifecycle. Executing the `build` task or the - specific `generateClassDiagrams` task automatically processes all source sets and places the output in the - configured directory. - + Code generation is fully integrated into the standard Gradle lifecycle. Executing the `build` task or the specific `generateClassDiagrams` task automatically processes all source sets and places the output in the configured directory. + ```groovy // build.gradle tasks.named("generateClassDiagrams") { @@ -403,46 +487,55 @@ the decorators and generate the actual Java source files. } ``` - # === "Gradle" - # Just like the CLI, the Gradle plugin does not generate fields for associations by default. You must explicitly configure the task to map these roles to Java fields. - # - # You can do this by setting the `fieldFromRole` property inside your generation task: - # - # ```groovy - # // build.gradle - # tasks.named("generateClassDiagrams") { - # // Set the target directory for the generated Java files - # getOutputDir().set(file("build/generated/sources/cdgen/main/java")) - # - # // Explicitly map navigable association roles to generated Java fields - # getFieldFromRole().set("navigable") - # } - # ``` +# === "Gradle" +# Just like the CLI, the Gradle plugin does not generate fields for associations by default. You must explicitly configure the task to map these roles to Java fields. +# +# You can do this by setting the `fieldFromRole` property inside your generation task: +# +# ```groovy +# // build.gradle +# tasks.named("generateClassDiagrams") { +# // Set the target directory for the generated Java files +# getOutputDir().set(file("build/generated/sources/cdgen/main/java")) +# +# // Explicitly map navigable association roles to generated Java fields +# getFieldFromRole().set("navigable") +# } +# ``` Running the CD4Code generator tooled into a Gradle build is as simple as executing the Gradle build task. -=== "Library" - ### Inspecting the Generated Code The generated code should now be located in the specified directory. Let's take a look at the generated code. +As by default, we use the `CD2Pojo` template, for configuring the Decorators, we are applying the `GetterDecorator`, +`SetterDecorator`, `CardinalityDecorator`, `NavigableSetterDecorator`, and `AbstactMethodDecorator` Decorators. +Therefore, we also expect the respecitive code artifacts to be generated. In our example, we should find the following files: ```text my-project/ -β”œβ”€β”€ src/ -β”‚ └── main/ -β”‚ β”œβ”€β”€ cds/ -β”‚ β”‚ └── MyCompany.cd -β”‚ └── java/ +β”œβ”€β”€ build/ +β”‚ β”œβ”€β”€ cdgensymbols/ +β”‚ β”œβ”€β”€ classes/ +β”‚ β”‚ └── java/ +β”‚ β”‚ └── main/ +β”‚ β”‚ └── MyOrganizer/ +β”‚ β”‚ β”œβ”€β”€ Asset.java +β”‚ β”‚ β”œβ”€β”€ Day.java +β”‚ β”‚ β”œβ”€β”€ Project.java +β”‚ β”‚ β”œβ”€β”€ Status.java +β”‚ β”‚ └── Task.java +β”‚ β”œβ”€β”€ generated/ +β”‚ └── generated-sources/ +β”‚ └── cdgen/ +β”‚ └── sourcecode/ +β”‚ └── MyOrganizer/ +β”‚ β”œβ”€β”€ Asset.java +β”‚ β”œβ”€β”€ Day.java +β”‚ β”œβ”€β”€ Project.java +β”‚ β”œβ”€β”€ Status.java +β”‚ └── Task.java β”œβ”€β”€ configTemplate/ β”‚ └── CD2OwnDecorator.ftl └── build.gradle README.md -``` - - - - - - - - +``` \ No newline at end of file diff --git a/docs/MyLife.cd b/docs/MyLife.cd deleted file mode 100644 index 4aa254925..000000000 --- a/docs/MyLife.cd +++ /dev/null @@ -1,27 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -// package monticore; - -import MyAddress.Address; -import java.lang.String; -import java.util.List; -import java.util.Date; - -classdiagram MyLife { - abstract class Person { - int age; - Date birthday; - List nickNames; - } - class PhoneNumber; - package uni { - class Student extends Person { - StudentStatus status; - -> Address [1..*] {ordered}; - } - class Grade; - enum StudentStatus { ENROLLED, FINISHED; } - composition uni.Student -> uni.Grade [*]; - association phonebook uni.Student [java.lang.String] -> PhoneNumber; - } - association [0..1] Person (parent) <-> (child) Person [*]; -} diff --git a/docs/MyLife.svg b/docs/MyLife.svg deleted file mode 100644 index 6c32e8f31..000000000 --- a/docs/MyLife.svg +++ /dev/null @@ -1,61 +0,0 @@ -monticore.MyLife CDmonticoreuniPersonint agejava.util.Date birthdayjava.util.List<java.lang.String> nickNamesPhoneNumberStudentStudentStatus statusGradeStudentStatusENROLLEDFINISHEDEnum ConstantsPhoneNumberAddressphonebookphonebookphonebookstudentgradestudentaddressparentchildgenerated with MontiCore using PlantUML diff --git a/docs/MyLifeNoDecorators.cd b/docs/MyLifeNoDecorators.cd deleted file mode 100644 index 39fae065b..000000000 --- a/docs/MyLifeNoDecorators.cd +++ /dev/null @@ -1,79 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - public String name; - public Date birthDate; - public String email; - - } - public abstract class Asset { - public String assetId; - public Date createdDate; - public Priority priority; - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - public String employeeId; - public double salary; - public Status employmentStatus; - public Listresponsibilities; - - } - public class Project extends Asset { - public String projectName; - public Date deadline; - public Listmilestones; - - } - public class Task extends Asset { - public String taskName; - public String description; - public Status taskStatus; - - } - public class Team { - public String teamName; - public int teamSize; - public ListteamMembers; - - } - public class Department { - public String deptName; - public String location; - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - - } - -} diff --git a/docs/MyLifeNoDecorators.svg b/docs/MyLifeNoDecorators.svg deleted file mode 100644 index 9ec00d981..000000000 --- a/docs/MyLifeNoDecorators.svg +++ /dev/null @@ -1,587 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - + String name; - - + Date birthDate; - - + String email; - - - - - - - - MyLife - - Β«abstractΒ» - Asset - - - + String assetId; - - + Date createdDate; - - + Priority priority; - - - - - - - - MyLife - - - Employee - - - + String employeeId; - - + double salary; - - + Status employmentStatus; - - + List<Priority>responsibilities; - - - - - - - - MyLife - - - Project - - - + String projectName; - - + Date deadline; - - + List<String>milestones; - - - - - - - - MyLife - - - Task - - - + String taskName; - - + String description; - - + Status taskStatus; - - - - - - - - MyLife - - - Team - - - + String teamName; - - + int teamSize; - - + List<String>teamMembers; - - - - - - - - MyLife - - - Department - - - + String deptName; - - + String location; - - - - - - - - CD - - - diff --git a/docs/MyLifeOnlyBuilders.cd b/docs/MyLifeOnlyBuilders.cd deleted file mode 100644 index 1c03425e1..000000000 --- a/docs/MyLifeOnlyBuilders.cd +++ /dev/null @@ -1,198 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - public String name; - public Date birthDate; - public String email; - - } - public abstract class Asset { - public String assetId; - public Date createdDate; - public Priority priority; - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - public String employeeId; - public double salary; - public Status employmentStatus; - public Listresponsibilities; - - } - public class Project extends Asset { - public String projectName; - public Date deadline; - public Listmilestones; - - } - public class Task extends Asset { - public String taskName; - public String description; - public Status taskStatus; - - } - public class Team { - public String teamName; - public int teamSize; - public ListteamMembers; - - } - public class Department { - public String deptName; - public String location; - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - public abstract class PersonBuilder { - protected PersonBuilder realBuilder; - public PersonBuilder(); - private boolean isValid(); - public Person build(); - public Person unsafeBuild(); - protected String name; - protected Date birthDate; - protected String email; - public PersonBuilder setName(String name); - public PersonBuilder setBirthDate(Date birthDate); - public PersonBuilder setEmail(String email); - - } - public abstract class AssetBuilder { - protected AssetBuilder realBuilder; - public AssetBuilder(); - private boolean isValid(); - public Asset build(); - public Asset unsafeBuild(); - protected String assetId; - protected Date createdDate; - protected Priority priority; - public AssetBuilder setAssetId(String assetId); - public AssetBuilder setCreatedDate(Date createdDate); - public AssetBuilder setPriority(Priority priority); - - } - public class EmployeeBuilder { - protected EmployeeBuilder realBuilder; - public EmployeeBuilder(); - private boolean isValid(); - public Employee build(); - public Employee unsafeBuild(); - protected String employeeId; - protected double salary; - protected Status employmentStatus; - protected Listresponsibilities; - protected String name; - protected Date birthDate; - protected String email; - public EmployeeBuilder setEmployeeId(String employeeId); - public EmployeeBuilder setSalary(double salary); - public EmployeeBuilder setEmploymentStatus(Status employmentStatus); - public EmployeeBuilder setResponsibilities(Listresponsibilities); - public EmployeeBuilder setName(String name); - public EmployeeBuilder setBirthDate(Date birthDate); - public EmployeeBuilder setEmail(String email); - public EmployeeBuilder setResponsibilitiesAbsent(); - - } - public class ProjectBuilder { - protected ProjectBuilder realBuilder; - public ProjectBuilder(); - private boolean isValid(); - public Project build(); - public Project unsafeBuild(); - protected String projectName; - protected Date deadline; - protected Listmilestones; - protected String assetId; - protected Date createdDate; - protected Priority priority; - public ProjectBuilder setProjectName(String projectName); - public ProjectBuilder setDeadline(Date deadline); - public ProjectBuilder setMilestones(Listmilestones); - public ProjectBuilder setAssetId(String assetId); - public ProjectBuilder setCreatedDate(Date createdDate); - public ProjectBuilder setPriority(Priority priority); - public ProjectBuilder setMilestonesAbsent(); - - } - public class TaskBuilder { - protected TaskBuilder realBuilder; - public TaskBuilder(); - private boolean isValid(); - public Task build(); - public Task unsafeBuild(); - protected String taskName; - protected String description; - protected Status taskStatus; - protected String assetId; - protected Date createdDate; - protected Priority priority; - public TaskBuilder setTaskName(String taskName); - public TaskBuilder setDescription(String description); - public TaskBuilder setTaskStatus(Status taskStatus); - public TaskBuilder setAssetId(String assetId); - public TaskBuilder setCreatedDate(Date createdDate); - public TaskBuilder setPriority(Priority priority); - - } - public class TeamBuilder { - protected TeamBuilder realBuilder; - public TeamBuilder(); - private boolean isValid(); - public Team build(); - public Team unsafeBuild(); - protected String teamName; - protected int teamSize; - protected ListteamMembers; - public TeamBuilder setTeamName(String teamName); - public TeamBuilder setTeamSize(int teamSize); - public TeamBuilder setTeamMembers(ListteamMembers); - public TeamBuilder setTeamMembersAbsent(); - - } - public class DepartmentBuilder { - protected DepartmentBuilder realBuilder; - public DepartmentBuilder(); - private boolean isValid(); - public Department build(); - public Department unsafeBuild(); - protected String deptName; - protected String location; - public DepartmentBuilder setDeptName(String deptName); - public DepartmentBuilder setLocation(String location); - - } - - } - -} diff --git a/docs/MyLifeOnlyBuilders.svg b/docs/MyLifeOnlyBuilders.svg deleted file mode 100644 index 5507c4cf3..000000000 --- a/docs/MyLifeOnlyBuilders.svg +++ /dev/null @@ -1,860 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - + String name; - - + Date birthDate; - - + String email; - - - - - - - - MyLife - - Β«abstractΒ» - Asset - - - + String assetId; - - + Date createdDate; - - + Priority priority; - - - - - - - - MyLife - - - Employee - - - + String employeeId; - - + double salary; - - + Status employmentStatus; - - + List<Priority>responsibilities; - - - - - - - - MyLife - - - Project - - - + String projectName; - - + Date deadline; - - + List<String>milestones; - - - - - - - - MyLife - - - Task - - - + String taskName; - - + String description; - - + Status taskStatus; - - - - - - - - MyLife - - - Team - - - + String teamName; - - + int teamSize; - - + List<String>teamMembers; - - - - - - - - MyLife - - - Department - - - + String deptName; - - + String location; - - - - - - - - MyLife - - Β«abstractΒ» - PersonBuilder - - - # PersonBuilder realBuilder; - - # String name; - - # Date birthDate; - - # String email; - - - - - - boolean isValid(); - - + Person build(); - - + Person unsafeBuild(); - - + PersonBuilder setName(String name); - - + PersonBuilder setBirthDate(Date birthDate); - - + PersonBuilder setEmail(String email); - - - - - - MyLife - - Β«abstractΒ» - AssetBuilder - - - # AssetBuilder realBuilder; - - # String assetId; - - # Date createdDate; - - # Priority priority; - - - - - - boolean isValid(); - - + Asset build(); - - + Asset unsafeBuild(); - - + AssetBuilder setAssetId(String assetId); - - + AssetBuilder setCreatedDate(Date createdDate); - - + AssetBuilder setPriority(Priority priority); - - - - - - MyLife - - - EmployeeBuilder - - - # EmployeeBuilder realBuilder; - - # String employeeId; - - # double salary; - - # Status employmentStatus; - - # List<Priority>responsibilities; - - # String name; - - # Date birthDate; - - # String email; - - - - - - boolean isValid(); - - + Employee build(); - - + Employee unsafeBuild(); - - + EmployeeBuilder setEmployeeId(String employeeId); - - + EmployeeBuilder setSalary(double salary); - - + EmployeeBuilder setEmploymentStatus(Status employmentStatus); - - + EmployeeBuilder setResponsibilities(List<Priority>responsibilities); - - + EmployeeBuilder setName(String name); - - + EmployeeBuilder setBirthDate(Date birthDate); - - + EmployeeBuilder setEmail(String email); - - + EmployeeBuilder setResponsibilitiesAbsent(); - - - - - - MyLife - - - ProjectBuilder - - - # ProjectBuilder realBuilder; - - # String projectName; - - # Date deadline; - - # List<String>milestones; - - # String assetId; - - # Date createdDate; - - # Priority priority; - - - - - - boolean isValid(); - - + Project build(); - - + Project unsafeBuild(); - - + ProjectBuilder setProjectName(String projectName); - - + ProjectBuilder setDeadline(Date deadline); - - + ProjectBuilder setMilestones(List<String>milestones); - - + ProjectBuilder setAssetId(String assetId); - - + ProjectBuilder setCreatedDate(Date createdDate); - - + ProjectBuilder setPriority(Priority priority); - - + ProjectBuilder setMilestonesAbsent(); - - - - - - MyLife - - - TaskBuilder - - - # TaskBuilder realBuilder; - - # String taskName; - - # String description; - - # Status taskStatus; - - # String assetId; - - # Date createdDate; - - # Priority priority; - - - - - - boolean isValid(); - - + Task build(); - - + Task unsafeBuild(); - - + TaskBuilder setTaskName(String taskName); - - + TaskBuilder setDescription(String description); - - + TaskBuilder setTaskStatus(Status taskStatus); - - + TaskBuilder setAssetId(String assetId); - - + TaskBuilder setCreatedDate(Date createdDate); - - + TaskBuilder setPriority(Priority priority); - - - - - - MyLife - - - TeamBuilder - - - # TeamBuilder realBuilder; - - # String teamName; - - # int teamSize; - - # List<String>teamMembers; - - - - - - boolean isValid(); - - + Team build(); - - + Team unsafeBuild(); - - + TeamBuilder setTeamName(String teamName); - - + TeamBuilder setTeamSize(int teamSize); - - + TeamBuilder setTeamMembers(List<String>teamMembers); - - + TeamBuilder setTeamMembersAbsent(); - - - - - - MyLife - - - DepartmentBuilder - - - # DepartmentBuilder realBuilder; - - # String deptName; - - # String location; - - - - - - boolean isValid(); - - + Department build(); - - + Department unsafeBuild(); - - + DepartmentBuilder setDeptName(String deptName); - - + DepartmentBuilder setLocation(String location); - - - - - - CD - - - diff --git a/docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd b/docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd deleted file mode 100644 index 3de03524f..000000000 --- a/docs/MyLifeOnlyDefaultsForCardinalityAttrs.cd +++ /dev/null @@ -1,82 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - public String name; - public Date birthDate; - public String email; - - } - public abstract class Asset { - public String assetId; - public Date createdDate; - public Priority priority; - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - public String employeeId; - public double salary; - public Status employmentStatus; - public Listresponsibilities; - public Employee(); - - } - public class Project extends Asset { - public String projectName; - public Date deadline; - public Listmilestones; - public Project(); - - } - public class Task extends Asset { - public String taskName; - public String description; - public Status taskStatus; - - } - public class Team { - public String teamName; - public int teamSize; - public ListteamMembers; - public Team(); - - } - public class Department { - public String deptName; - public String location; - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - - } - -} diff --git a/docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg b/docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg deleted file mode 100644 index 9ec00d981..000000000 --- a/docs/MyLifeOnlyDefaultsForCardinalityAttrs.svg +++ /dev/null @@ -1,587 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - + String name; - - + Date birthDate; - - + String email; - - - - - - - - MyLife - - Β«abstractΒ» - Asset - - - + String assetId; - - + Date createdDate; - - + Priority priority; - - - - - - - - MyLife - - - Employee - - - + String employeeId; - - + double salary; - - + Status employmentStatus; - - + List<Priority>responsibilities; - - - - - - - - MyLife - - - Project - - - + String projectName; - - + Date deadline; - - + List<String>milestones; - - - - - - - - MyLife - - - Task - - - + String taskName; - - + String description; - - + Status taskStatus; - - - - - - - - MyLife - - - Team - - - + String teamName; - - + int teamSize; - - + List<String>teamMembers; - - - - - - - - MyLife - - - Department - - - + String deptName; - - + String location; - - - - - - - - CD - - - diff --git a/docs/MyLifeOnlyGetter.cd b/docs/MyLifeOnlyGetter.cd deleted file mode 100644 index f2cb53ef0..000000000 --- a/docs/MyLifeOnlyGetter.cd +++ /dev/null @@ -1,154 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - protected String name; - protected Date birthDate; - protected String email; - public String getName(); - public Date getBirthDate(); - public String getEmail(); - - } - public abstract class Asset { - protected String assetId; - protected Date createdDate; - protected Priority priority; - public String getAssetId(); - public Date getCreatedDate(); - public Priority getPriority(); - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - protected String employeeId; - protected double salary; - protected Status employmentStatus; - protected Listresponsibilities; - public String getEmployeeId(); - public double getSalary(); - public Status getEmploymentStatus(); - public ListgetResponsibilities(); - public boolean containsResponsibilities(Object element); - public boolean containsAllResponsibilities(java.util.Collectioncollection); - public boolean isEmptyResponsibilities(); - public java.util.IteratoriteratorResponsibilities(); - public int sizeResponsibilities(); - public Priority []toArrayResponsibilities(Priority []array); - public Object []toArrayResponsibilities(); - public java.util.SpliteratorspliteratorResponsibilities(); - public java.util.stream.StreamstreamResponsibilities(); - public java.util.stream.StreamparallelStreamResponsibilities(); - public boolean equalsResponsibilities(Object o); - public int hashCodeResponsibilities(); - public Priority getResponsibilities(int index); - public int indexOfResponsibilities(Object element); - public int lastIndexOfResponsibilities(Object element); - public java.util.ListIteratorlistIteratorResponsibilities(); - public java.util.ListIteratorlistIteratorResponsibilities(int index); - public java.util.ListsubListResponsibilities(int start,int end); - - } - public class Project extends Asset { - protected String projectName; - protected Date deadline; - protected Listmilestones; - public String getProjectName(); - public Date getDeadline(); - public ListgetMilestones(); - public boolean containsMilestones(Object element); - public boolean containsAllMilestones(java.util.Collectioncollection); - public boolean isEmptyMilestones(); - public java.util.IteratoriteratorMilestones(); - public int sizeMilestones(); - public String []toArrayMilestones(String []array); - public Object []toArrayMilestones(); - public java.util.SpliteratorspliteratorMilestones(); - public java.util.stream.StreamstreamMilestones(); - public java.util.stream.StreamparallelStreamMilestones(); - public boolean equalsMilestones(Object o); - public int hashCodeMilestones(); - public String getMilestones(int index); - public int indexOfMilestones(Object element); - public int lastIndexOfMilestones(Object element); - public java.util.ListIteratorlistIteratorMilestones(); - public java.util.ListIteratorlistIteratorMilestones(int index); - public java.util.ListsubListMilestones(int start,int end); - - } - public class Task extends Asset { - protected String taskName; - protected String description; - protected Status taskStatus; - public String getTaskName(); - public String getDescription(); - public Status getTaskStatus(); - - } - public class Team { - protected String teamName; - protected int teamSize; - protected ListteamMembers; - public String getTeamName(); - public int getTeamSize(); - public ListgetTeamMembers(); - public boolean containsTeamMembers(Object element); - public boolean containsAllTeamMembers(java.util.Collectioncollection); - public boolean isEmptyTeamMembers(); - public java.util.IteratoriteratorTeamMembers(); - public int sizeTeamMembers(); - public String []toArrayTeamMembers(String []array); - public Object []toArrayTeamMembers(); - public java.util.SpliteratorspliteratorTeamMembers(); - public java.util.stream.StreamstreamTeamMembers(); - public java.util.stream.StreamparallelStreamTeamMembers(); - public boolean equalsTeamMembers(Object o); - public int hashCodeTeamMembers(); - public String getTeamMembers(int index); - public int indexOfTeamMembers(Object element); - public int lastIndexOfTeamMembers(Object element); - public java.util.ListIteratorlistIteratorTeamMembers(); - public java.util.ListIteratorlistIteratorTeamMembers(int index); - public java.util.ListsubListTeamMembers(int start,int end); - - } - public class Department { - protected String deptName; - protected String location; - public String getDeptName(); - public String getLocation(); - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - - } - -} diff --git a/docs/MyLifeOnlyGetter.svg b/docs/MyLifeOnlyGetter.svg deleted file mode 100644 index d4c0bea93..000000000 --- a/docs/MyLifeOnlyGetter.svg +++ /dev/null @@ -1,744 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - # String name; - - # Date birthDate; - - # String email; - - - - - + String getName(); - - + Date getBirthDate(); - - + String getEmail(); - - - - - - MyLife - - Β«abstractΒ» - Asset - - - # String assetId; - - # Date createdDate; - - # Priority priority; - - - - - + String getAssetId(); - - + Date getCreatedDate(); - - + Priority getPriority(); - - - - - - MyLife - - - Employee - - - # String employeeId; - - # double salary; - - # Status employmentStatus; - - # List<Priority>responsibilities; - - - - - + String getEmployeeId(); - - + double getSalary(); - - + Status getEmploymentStatus(); - - + List<Priority>getResponsibilities(); - - + boolean containsResponsibilities(Object element); - - + boolean containsAllResponsibilities(java.util.Collection<?>collection); - - + boolean isEmptyResponsibilities(); - - + java.util.Iterator<Priority>iteratorResponsibilities(); - - + int sizeResponsibilities(); - - + Priority []toArrayResponsibilities(Priority []array); - - + Object []toArrayResponsibilities(); - - + java.util.Spliterator<Priority>spliteratorResponsibilities(); - - + java.util.stream.Stream<Priority>streamResponsibilities(); - - + java.util.stream.Stream<Priority>parallelStreamResponsibilities(); - - + boolean equalsResponsibilities(Object o); - - + int hashCodeResponsibilities(); - - + Priority getResponsibilities(int index); - - + int indexOfResponsibilities(Object element); - - + int lastIndexOfResponsibilities(Object element); - - + java.util.ListIterator<Priority>listIteratorResponsibilities(); - - + java.util.ListIterator<Priority>listIteratorResponsibilities(int index); - - + java.util.List<Priority>subListResponsibilities(int start,int end); - - - - - - MyLife - - - Project - - - # String projectName; - - # Date deadline; - - # List<String>milestones; - - - - - + String getProjectName(); - - + Date getDeadline(); - - + List<String>getMilestones(); - - + boolean containsMilestones(Object element); - - + boolean containsAllMilestones(java.util.Collection<?>collection); - - + boolean isEmptyMilestones(); - - + java.util.Iterator<String>iteratorMilestones(); - - + int sizeMilestones(); - - + String []toArrayMilestones(String []array); - - + Object []toArrayMilestones(); - - + java.util.Spliterator<String>spliteratorMilestones(); - - + java.util.stream.Stream<String>streamMilestones(); - - + java.util.stream.Stream<String>parallelStreamMilestones(); - - + boolean equalsMilestones(Object o); - - + int hashCodeMilestones(); - - + String getMilestones(int index); - - + int indexOfMilestones(Object element); - - + int lastIndexOfMilestones(Object element); - - + java.util.ListIterator<String>listIteratorMilestones(); - - + java.util.ListIterator<String>listIteratorMilestones(int index); - - + java.util.List<String>subListMilestones(int start,int end); - - - - - - MyLife - - - Task - - - # String taskName; - - # String description; - - # Status taskStatus; - - - - - + String getTaskName(); - - + String getDescription(); - - + Status getTaskStatus(); - - - - - - MyLife - - - Team - - - # String teamName; - - # int teamSize; - - # List<String>teamMembers; - - - - - + String getTeamName(); - - + int getTeamSize(); - - + List<String>getTeamMembers(); - - + boolean containsTeamMembers(Object element); - - + boolean containsAllTeamMembers(java.util.Collection<?>collection); - - + boolean isEmptyTeamMembers(); - - + java.util.Iterator<String>iteratorTeamMembers(); - - + int sizeTeamMembers(); - - + String []toArrayTeamMembers(String []array); - - + Object []toArrayTeamMembers(); - - + java.util.Spliterator<String>spliteratorTeamMembers(); - - + java.util.stream.Stream<String>streamTeamMembers(); - - + java.util.stream.Stream<String>parallelStreamTeamMembers(); - - + boolean equalsTeamMembers(Object o); - - + int hashCodeTeamMembers(); - - + String getTeamMembers(int index); - - + int indexOfTeamMembers(Object element); - - + int lastIndexOfTeamMembers(Object element); - - + java.util.ListIterator<String>listIteratorTeamMembers(); - - + java.util.ListIterator<String>listIteratorTeamMembers(int index); - - + java.util.List<String>subListTeamMembers(int start,int end); - - - - - - MyLife - - - Department - - - # String deptName; - - # String location; - - - - - + String getDeptName(); - - + String getLocation(); - - - - - - CD - - - diff --git a/docs/MyLifeOnlyNavigableSetter.cd b/docs/MyLifeOnlyNavigableSetter.cd deleted file mode 100644 index d49793f87..000000000 --- a/docs/MyLifeOnlyNavigableSetter.cd +++ /dev/null @@ -1,103 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - protected String name; - protected Date birthDate; - protected String email; - public void setName(String name); - public void setBirthDate(Date birthDate); - public void setEmail(String email); - - } - public abstract class Asset { - protected String assetId; - protected Date createdDate; - protected Priority priority; - public void setAssetId(String assetId); - public void setCreatedDate(Date createdDate); - public void setPriority(Priority priority); - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - protected String employeeId; - protected double salary; - protected Status employmentStatus; - protected Listresponsibilities; - public void setEmployeeId(String employeeId); - public void setSalary(double salary); - public void setEmploymentStatus(Status employmentStatus); - public void addResponsibilities(int index,Priority responsibilities); - public Priority removeResponsibilities(int index); - - } - public class Project extends Asset { - protected String projectName; - protected Date deadline; - protected Listmilestones; - public void setProjectName(String projectName); - public void setDeadline(Date deadline); - public void addMilestones(int index,String milestones); - public String removeMilestones(int index); - - } - public class Task extends Asset { - protected String taskName; - protected String description; - protected Status taskStatus; - public void setTaskName(String taskName); - public void setDescription(String description); - public void setTaskStatus(Status taskStatus); - - } - public class Team { - protected String teamName; - protected int teamSize; - protected ListteamMembers; - public void setTeamName(String teamName); - public void setTeamSize(int teamSize); - public void addTeamMembers(int index,String teamMembers); - public String removeTeamMembers(int index); - - } - public class Department { - protected String deptName; - protected String location; - public void setDeptName(String deptName); - public void setLocation(String location); - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - - } - -} diff --git a/docs/MyLifeOnlyNavigableSetter.svg b/docs/MyLifeOnlyNavigableSetter.svg deleted file mode 100644 index 0e486e474..000000000 --- a/docs/MyLifeOnlyNavigableSetter.svg +++ /dev/null @@ -1,642 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - # String name; - - # Date birthDate; - - # String email; - - - - - + void setName(String name); - - + void setBirthDate(Date birthDate); - - + void setEmail(String email); - - - - - - MyLife - - Β«abstractΒ» - Asset - - - # String assetId; - - # Date createdDate; - - # Priority priority; - - - - - + void setAssetId(String assetId); - - + void setCreatedDate(Date createdDate); - - + void setPriority(Priority priority); - - - - - - MyLife - - - Employee - - - # String employeeId; - - # double salary; - - # Status employmentStatus; - - # List<Priority>responsibilities; - - - - - + void setEmployeeId(String employeeId); - - + void setSalary(double salary); - - + void setEmploymentStatus(Status employmentStatus); - - + void addResponsibilities(int index,Priority responsibilities); - - + Priority removeResponsibilities(int index); - - - - - - MyLife - - - Project - - - # String projectName; - - # Date deadline; - - # List<String>milestones; - - - - - + void setProjectName(String projectName); - - + void setDeadline(Date deadline); - - + void addMilestones(int index,String milestones); - - + String removeMilestones(int index); - - - - - - MyLife - - - Task - - - # String taskName; - - # String description; - - # Status taskStatus; - - - - - + void setTaskName(String taskName); - - + void setDescription(String description); - - + void setTaskStatus(Status taskStatus); - - - - - - MyLife - - - Team - - - # String teamName; - - # int teamSize; - - # List<String>teamMembers; - - - - - + void setTeamName(String teamName); - - + void setTeamSize(int teamSize); - - + void addTeamMembers(int index,String teamMembers); - - + String removeTeamMembers(int index); - - - - - - MyLife - - - Department - - - # String deptName; - - # String location; - - - - - + void setDeptName(String deptName); - - + void setLocation(String location); - - - - - - CD - - - diff --git a/docs/MyLifeOnlyObservers.cd b/docs/MyLifeOnlyObservers.cd deleted file mode 100644 index 8ba6bac27..000000000 --- a/docs/MyLifeOnlyObservers.cd +++ /dev/null @@ -1,183 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person implements de.monticore.cd.ICDObservable{ - public String name; - public Date birthDate; - public String email; - protected ListobserverList; - public void addObserver(MyLife.IPersonObserver observer); - public void removeObserver(MyLife.IPersonObserver observer); - protected void notifyObservers(); - protected void notifyObserversSetName(String ov); - protected void notifyObserversSetBirthDate(Date ov); - protected void notifyObserversSetEmail(String ov); - - } - public abstract class Asset implements de.monticore.cd.ICDObservable{ - public String assetId; - public Date createdDate; - public Priority priority; - protected ListobserverList; - public void addObserver(MyLife.IAssetObserver observer); - public void removeObserver(MyLife.IAssetObserver observer); - protected void notifyObservers(); - protected void notifyObserversSetAssetId(String ov); - protected void notifyObserversSetCreatedDate(Date ov); - protected void notifyObserversSetPriority(Priority ov); - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person implements de.monticore.cd.ICDObservable{ - public String employeeId; - public double salary; - public Status employmentStatus; - public Listresponsibilities; - protected ListobserverList; - public void addObserver(MyLife.IEmployeeObserver observer); - public void removeObserver(MyLife.IEmployeeObserver observer); - protected void notifyObservers(); - protected void notifyObserversSetEmployeeId(String ov); - protected void notifyObserversSetSalary(double ov); - protected void notifyObserversSetEmploymentStatus(Status ov); - protected void notifyObserversAddResponsibilities(int index,Priority newElem); - protected void notifyObserversRemoveResponsibilities(int index,Priority elem); - - } - public class Project extends Asset implements de.monticore.cd.ICDObservable{ - public String projectName; - public Date deadline; - public Listmilestones; - protected ListobserverList; - public void addObserver(MyLife.IProjectObserver observer); - public void removeObserver(MyLife.IProjectObserver observer); - protected void notifyObservers(); - protected void notifyObserversSetProjectName(String ov); - protected void notifyObserversSetDeadline(Date ov); - protected void notifyObserversAddMilestones(int index,String newElem); - protected void notifyObserversRemoveMilestones(int index,String elem); - - } - public class Task extends Asset implements de.monticore.cd.ICDObservable{ - public String taskName; - public String description; - public Status taskStatus; - protected ListobserverList; - public void addObserver(MyLife.ITaskObserver observer); - public void removeObserver(MyLife.ITaskObserver observer); - protected void notifyObservers(); - protected void notifyObserversSetTaskName(String ov); - protected void notifyObserversSetDescription(String ov); - protected void notifyObserversSetTaskStatus(Status ov); - - } - public class Team implements de.monticore.cd.ICDObservable{ - public String teamName; - public int teamSize; - public ListteamMembers; - protected ListobserverList; - public void addObserver(MyLife.ITeamObserver observer); - public void removeObserver(MyLife.ITeamObserver observer); - protected void notifyObservers(); - protected void notifyObserversSetTeamName(String ov); - protected void notifyObserversSetTeamSize(int ov); - protected void notifyObserversAddTeamMembers(int index,String newElem); - protected void notifyObserversRemoveTeamMembers(int index,String elem); - - } - public class Department implements de.monticore.cd.ICDObservable{ - public String deptName; - public String location; - protected ListobserverList; - public void addObserver(MyLife.IDepartmentObserver observer); - public void removeObserver(MyLife.IDepartmentObserver observer); - protected void notifyObservers(); - protected void notifyObserversSetDeptName(String ov); - protected void notifyObserversSetLocation(String ov); - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - public interface IPersonObserver extends de.monticore.cd.ICDObserver{ - public void notifyUpdate(Person clazz); - public void notifyUpdateSetName(Person clazz,String ov); - public void notifyUpdateSetBirthDate(Person clazz,Date ov); - public void notifyUpdateSetEmail(Person clazz,String ov); - - } - public interface IAssetObserver extends de.monticore.cd.ICDObserver{ - public void notifyUpdate(Asset clazz); - public void notifyUpdateSetAssetId(Asset clazz,String ov); - public void notifyUpdateSetCreatedDate(Asset clazz,Date ov); - public void notifyUpdateSetPriority(Asset clazz,Priority ov); - - } - public interface IEmployeeObserver extends de.monticore.cd.ICDObserver{ - public void notifyUpdate(Employee clazz); - public void notifyUpdateSetEmployeeId(Employee clazz,String ov); - public void notifyUpdateSetSalary(Employee clazz,double ov); - public void notifyUpdateSetEmploymentStatus(Employee clazz,Status ov); - public void notifyUpdateAddResponsibilities(Employee clazz,int index,Priority newElem); - public void notifyUpdateRemoveResponsibilities(Employee clazz,int index,Priority elem); - - } - public interface IProjectObserver extends de.monticore.cd.ICDObserver{ - public void notifyUpdate(Project clazz); - public void notifyUpdateSetProjectName(Project clazz,String ov); - public void notifyUpdateSetDeadline(Project clazz,Date ov); - public void notifyUpdateAddMilestones(Project clazz,int index,String newElem); - public void notifyUpdateRemoveMilestones(Project clazz,int index,String elem); - - } - public interface ITaskObserver extends de.monticore.cd.ICDObserver{ - public void notifyUpdate(Task clazz); - public void notifyUpdateSetTaskName(Task clazz,String ov); - public void notifyUpdateSetDescription(Task clazz,String ov); - public void notifyUpdateSetTaskStatus(Task clazz,Status ov); - - } - public interface ITeamObserver extends de.monticore.cd.ICDObserver{ - public void notifyUpdate(Team clazz); - public void notifyUpdateSetTeamName(Team clazz,String ov); - public void notifyUpdateSetTeamSize(Team clazz,int ov); - public void notifyUpdateAddTeamMembers(Team clazz,int index,String newElem); - public void notifyUpdateRemoveTeamMembers(Team clazz,int index,String elem); - - } - public interface IDepartmentObserver extends de.monticore.cd.ICDObserver{ - public void notifyUpdate(Department clazz); - public void notifyUpdateSetDeptName(Department clazz,String ov); - public void notifyUpdateSetLocation(Department clazz,String ov); - - } - - } - -} diff --git a/docs/MyLifeOnlyObservers.svg b/docs/MyLifeOnlyObservers.svg deleted file mode 100644 index 3ade290fa..000000000 --- a/docs/MyLifeOnlyObservers.svg +++ /dev/null @@ -1,844 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - + String name; - - + Date birthDate; - - + String email; - - # List<MyLife.IPersonObserver>observerList; - - - - - + void addObserver(MyLife.IPersonObserver observer); - - + void removeObserver(MyLife.IPersonObserver observer); - - # void notifyObservers(); - - # void notifyObserversSetName(String ov); - - # void notifyObserversSetBirthDate(Date ov); - - # void notifyObserversSetEmail(String ov); - - - - - - MyLife - - Β«abstractΒ» - Asset - - - + String assetId; - - + Date createdDate; - - + Priority priority; - - # List<MyLife.IAssetObserver>observerList; - - - - - + void addObserver(MyLife.IAssetObserver observer); - - + void removeObserver(MyLife.IAssetObserver observer); - - # void notifyObservers(); - - # void notifyObserversSetAssetId(String ov); - - # void notifyObserversSetCreatedDate(Date ov); - - # void notifyObserversSetPriority(Priority ov); - - - - - - MyLife - - - Employee - - - + String employeeId; - - + double salary; - - + Status employmentStatus; - - + List<Priority>responsibilities; - - # List<MyLife.IEmployeeObserver>observerList; - - - - - + void addObserver(MyLife.IEmployeeObserver observer); - - + void removeObserver(MyLife.IEmployeeObserver observer); - - # void notifyObservers(); - - # void notifyObserversSetEmployeeId(String ov); - - # void notifyObserversSetSalary(double ov); - - # void notifyObserversSetEmploymentStatus(Status ov); - - # void notifyObserversAddResponsibilities(int index,Priority newElem); - - # void notifyObserversRemoveResponsibilities(int index,Priority elem); - - - - - - MyLife - - - Project - - - + String projectName; - - + Date deadline; - - + List<String>milestones; - - # List<MyLife.IProjectObserver>observerList; - - - - - + void addObserver(MyLife.IProjectObserver observer); - - + void removeObserver(MyLife.IProjectObserver observer); - - # void notifyObservers(); - - # void notifyObserversSetProjectName(String ov); - - # void notifyObserversSetDeadline(Date ov); - - # void notifyObserversAddMilestones(int index,String newElem); - - # void notifyObserversRemoveMilestones(int index,String elem); - - - - - - MyLife - - - Task - - - + String taskName; - - + String description; - - + Status taskStatus; - - # List<MyLife.ITaskObserver>observerList; - - - - - + void addObserver(MyLife.ITaskObserver observer); - - + void removeObserver(MyLife.ITaskObserver observer); - - # void notifyObservers(); - - # void notifyObserversSetTaskName(String ov); - - # void notifyObserversSetDescription(String ov); - - # void notifyObserversSetTaskStatus(Status ov); - - - - - - MyLife - - - Team - - - + String teamName; - - + int teamSize; - - + List<String>teamMembers; - - # List<MyLife.ITeamObserver>observerList; - - - - - + void addObserver(MyLife.ITeamObserver observer); - - + void removeObserver(MyLife.ITeamObserver observer); - - # void notifyObservers(); - - # void notifyObserversSetTeamName(String ov); - - # void notifyObserversSetTeamSize(int ov); - - # void notifyObserversAddTeamMembers(int index,String newElem); - - # void notifyObserversRemoveTeamMembers(int index,String elem); - - - - - - MyLife - - - Department - - - + String deptName; - - + String location; - - # List<MyLife.IDepartmentObserver>observerList; - - - - - + void addObserver(MyLife.IDepartmentObserver observer); - - + void removeObserver(MyLife.IDepartmentObserver observer); - - # void notifyObservers(); - - # void notifyObserversSetDeptName(String ov); - - # void notifyObserversSetLocation(String ov); - - - - - - MyLife - - Β«interfaceΒ» - IPersonObserver - - - - - + void notifyUpdate(Person clazz); - - + void notifyUpdateSetName(Person clazz,String ov); - - + void notifyUpdateSetBirthDate(Person clazz,Date ov); - - + void notifyUpdateSetEmail(Person clazz,String ov); - - - - - - MyLife - - Β«interfaceΒ» - IAssetObserver - - - - - + void notifyUpdate(Asset clazz); - - + void notifyUpdateSetAssetId(Asset clazz,String ov); - - + void notifyUpdateSetCreatedDate(Asset clazz,Date ov); - - + void notifyUpdateSetPriority(Asset clazz,Priority ov); - - - - - - MyLife - - Β«interfaceΒ» - IEmployeeObserver - - - - - + void notifyUpdate(Employee clazz); - - + void notifyUpdateSetEmployeeId(Employee clazz,String ov); - - + void notifyUpdateSetSalary(Employee clazz,double ov); - - + void notifyUpdateSetEmploymentStatus(Employee clazz,Status ov); - - + void notifyUpdateAddResponsibilities(Employee clazz,int index,Priority newElem); - - + void notifyUpdateRemoveResponsibilities(Employee clazz,int index,Priority elem); - - - - - - MyLife - - Β«interfaceΒ» - IProjectObserver - - - - - + void notifyUpdate(Project clazz); - - + void notifyUpdateSetProjectName(Project clazz,String ov); - - + void notifyUpdateSetDeadline(Project clazz,Date ov); - - + void notifyUpdateAddMilestones(Project clazz,int index,String newElem); - - + void notifyUpdateRemoveMilestones(Project clazz,int index,String elem); - - - - - - MyLife - - Β«interfaceΒ» - ITaskObserver - - - - - + void notifyUpdate(Task clazz); - - + void notifyUpdateSetTaskName(Task clazz,String ov); - - + void notifyUpdateSetDescription(Task clazz,String ov); - - + void notifyUpdateSetTaskStatus(Task clazz,Status ov); - - - - - - MyLife - - Β«interfaceΒ» - ITeamObserver - - - - - + void notifyUpdate(Team clazz); - - + void notifyUpdateSetTeamName(Team clazz,String ov); - - + void notifyUpdateSetTeamSize(Team clazz,int ov); - - + void notifyUpdateAddTeamMembers(Team clazz,int index,String newElem); - - + void notifyUpdateRemoveTeamMembers(Team clazz,int index,String elem); - - - - - - MyLife - - Β«interfaceΒ» - IDepartmentObserver - - - - - + void notifyUpdate(Department clazz); - - + void notifyUpdateSetDeptName(Department clazz,String ov); - - + void notifyUpdateSetLocation(Department clazz,String ov); - - - - - - CD - - - diff --git a/docs/MyLifeOnlySetter.cd b/docs/MyLifeOnlySetter.cd deleted file mode 100644 index d49793f87..000000000 --- a/docs/MyLifeOnlySetter.cd +++ /dev/null @@ -1,103 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - protected String name; - protected Date birthDate; - protected String email; - public void setName(String name); - public void setBirthDate(Date birthDate); - public void setEmail(String email); - - } - public abstract class Asset { - protected String assetId; - protected Date createdDate; - protected Priority priority; - public void setAssetId(String assetId); - public void setCreatedDate(Date createdDate); - public void setPriority(Priority priority); - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - protected String employeeId; - protected double salary; - protected Status employmentStatus; - protected Listresponsibilities; - public void setEmployeeId(String employeeId); - public void setSalary(double salary); - public void setEmploymentStatus(Status employmentStatus); - public void addResponsibilities(int index,Priority responsibilities); - public Priority removeResponsibilities(int index); - - } - public class Project extends Asset { - protected String projectName; - protected Date deadline; - protected Listmilestones; - public void setProjectName(String projectName); - public void setDeadline(Date deadline); - public void addMilestones(int index,String milestones); - public String removeMilestones(int index); - - } - public class Task extends Asset { - protected String taskName; - protected String description; - protected Status taskStatus; - public void setTaskName(String taskName); - public void setDescription(String description); - public void setTaskStatus(Status taskStatus); - - } - public class Team { - protected String teamName; - protected int teamSize; - protected ListteamMembers; - public void setTeamName(String teamName); - public void setTeamSize(int teamSize); - public void addTeamMembers(int index,String teamMembers); - public String removeTeamMembers(int index); - - } - public class Department { - protected String deptName; - protected String location; - public void setDeptName(String deptName); - public void setLocation(String location); - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - - } - -} diff --git a/docs/MyLifeOnlySetter.svg b/docs/MyLifeOnlySetter.svg deleted file mode 100644 index 0e486e474..000000000 --- a/docs/MyLifeOnlySetter.svg +++ /dev/null @@ -1,642 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - # String name; - - # Date birthDate; - - # String email; - - - - - + void setName(String name); - - + void setBirthDate(Date birthDate); - - + void setEmail(String email); - - - - - - MyLife - - Β«abstractΒ» - Asset - - - # String assetId; - - # Date createdDate; - - # Priority priority; - - - - - + void setAssetId(String assetId); - - + void setCreatedDate(Date createdDate); - - + void setPriority(Priority priority); - - - - - - MyLife - - - Employee - - - # String employeeId; - - # double salary; - - # Status employmentStatus; - - # List<Priority>responsibilities; - - - - - + void setEmployeeId(String employeeId); - - + void setSalary(double salary); - - + void setEmploymentStatus(Status employmentStatus); - - + void addResponsibilities(int index,Priority responsibilities); - - + Priority removeResponsibilities(int index); - - - - - - MyLife - - - Project - - - # String projectName; - - # Date deadline; - - # List<String>milestones; - - - - - + void setProjectName(String projectName); - - + void setDeadline(Date deadline); - - + void addMilestones(int index,String milestones); - - + String removeMilestones(int index); - - - - - - MyLife - - - Task - - - # String taskName; - - # String description; - - # Status taskStatus; - - - - - + void setTaskName(String taskName); - - + void setDescription(String description); - - + void setTaskStatus(Status taskStatus); - - - - - - MyLife - - - Team - - - # String teamName; - - # int teamSize; - - # List<String>teamMembers; - - - - - + void setTeamName(String teamName); - - + void setTeamSize(int teamSize); - - + void addTeamMembers(int index,String teamMembers); - - + String removeTeamMembers(int index); - - - - - - MyLife - - - Department - - - # String deptName; - - # String location; - - - - - + void setDeptName(String deptName); - - + void setLocation(String location); - - - - - - CD - - - diff --git a/docs/MyLifeOnlyVisitors.cd b/docs/MyLifeOnlyVisitors.cd deleted file mode 100644 index be21090e7..000000000 --- a/docs/MyLifeOnlyVisitors.cd +++ /dev/null @@ -1,182 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - protected String name; - protected Date birthDate; - protected String email; - public String getName(); - public Date getBirthDate(); - public String getEmail(); - public void accept(MyLife.IMyLifeVisitor visitor); - - } - public abstract class Asset { - protected String assetId; - protected Date createdDate; - protected Priority priority; - public String getAssetId(); - public Date getCreatedDate(); - public Priority getPriority(); - public void accept(MyLife.IMyLifeVisitor visitor); - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - protected String employeeId; - protected double salary; - protected Status employmentStatus; - protected Listresponsibilities; - public String getEmployeeId(); - public double getSalary(); - public Status getEmploymentStatus(); - public ListgetResponsibilities(); - public boolean containsResponsibilities(Object element); - public boolean containsAllResponsibilities(java.util.Collectioncollection); - public boolean isEmptyResponsibilities(); - public java.util.IteratoriteratorResponsibilities(); - public int sizeResponsibilities(); - public Priority []toArrayResponsibilities(Priority []array); - public Object []toArrayResponsibilities(); - public java.util.SpliteratorspliteratorResponsibilities(); - public java.util.stream.StreamstreamResponsibilities(); - public java.util.stream.StreamparallelStreamResponsibilities(); - public boolean equalsResponsibilities(Object o); - public int hashCodeResponsibilities(); - public Priority getResponsibilities(int index); - public int indexOfResponsibilities(Object element); - public int lastIndexOfResponsibilities(Object element); - public java.util.ListIteratorlistIteratorResponsibilities(); - public java.util.ListIteratorlistIteratorResponsibilities(int index); - public java.util.ListsubListResponsibilities(int start,int end); - public void accept(MyLife.IMyLifeVisitor visitor); - - } - public class Project extends Asset { - protected String projectName; - protected Date deadline; - protected Listmilestones; - public String getProjectName(); - public Date getDeadline(); - public ListgetMilestones(); - public boolean containsMilestones(Object element); - public boolean containsAllMilestones(java.util.Collectioncollection); - public boolean isEmptyMilestones(); - public java.util.IteratoriteratorMilestones(); - public int sizeMilestones(); - public String []toArrayMilestones(String []array); - public Object []toArrayMilestones(); - public java.util.SpliteratorspliteratorMilestones(); - public java.util.stream.StreamstreamMilestones(); - public java.util.stream.StreamparallelStreamMilestones(); - public boolean equalsMilestones(Object o); - public int hashCodeMilestones(); - public String getMilestones(int index); - public int indexOfMilestones(Object element); - public int lastIndexOfMilestones(Object element); - public java.util.ListIteratorlistIteratorMilestones(); - public java.util.ListIteratorlistIteratorMilestones(int index); - public java.util.ListsubListMilestones(int start,int end); - public void accept(MyLife.IMyLifeVisitor visitor); - - } - public class Task extends Asset { - protected String taskName; - protected String description; - protected Status taskStatus; - public String getTaskName(); - public String getDescription(); - public Status getTaskStatus(); - public void accept(MyLife.IMyLifeVisitor visitor); - - } - public class Team { - protected String teamName; - protected int teamSize; - protected ListteamMembers; - public String getTeamName(); - public int getTeamSize(); - public ListgetTeamMembers(); - public boolean containsTeamMembers(Object element); - public boolean containsAllTeamMembers(java.util.Collectioncollection); - public boolean isEmptyTeamMembers(); - public java.util.IteratoriteratorTeamMembers(); - public int sizeTeamMembers(); - public String []toArrayTeamMembers(String []array); - public Object []toArrayTeamMembers(); - public java.util.SpliteratorspliteratorTeamMembers(); - public java.util.stream.StreamstreamTeamMembers(); - public java.util.stream.StreamparallelStreamTeamMembers(); - public boolean equalsTeamMembers(Object o); - public int hashCodeTeamMembers(); - public String getTeamMembers(int index); - public int indexOfTeamMembers(Object element); - public int lastIndexOfTeamMembers(Object element); - public java.util.ListIteratorlistIteratorTeamMembers(); - public java.util.ListIteratorlistIteratorTeamMembers(int index); - public java.util.ListsubListTeamMembers(int start,int end); - public void accept(MyLife.IMyLifeVisitor visitor); - - } - public class Department { - protected String deptName; - protected String location; - public String getDeptName(); - public String getLocation(); - public void accept(MyLife.IMyLifeVisitor visitor); - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - public interface IMyLifeVisitor { - public abstract void visit(Person node); - public abstract void visit(Asset node); - public abstract void visit(Employee node); - public abstract void visit(Project node); - public abstract void visit(Task node); - public abstract void visit(Team node); - public abstract void visit(Department node); - - } - public class MyLifeVisitorImplementation implements IMyLifeVisitor { - protected CollectiontraversedElements; - public void visit(Person node); - public void visit(Asset node); - public void visit(Employee node); - public void visit(Project node); - public void visit(Task node); - public void visit(Team node); - public void visit(Department node); - - } - - } - -} diff --git a/docs/MyLifeOnlyVisitors.svg b/docs/MyLifeOnlyVisitors.svg deleted file mode 100644 index f050bafd1..000000000 --- a/docs/MyLifeOnlyVisitors.svg +++ /dev/null @@ -1,820 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - # String name; - - # Date birthDate; - - # String email; - - - - - + String getName(); - - + Date getBirthDate(); - - + String getEmail(); - - + void accept(MyLife.IMyLifeVisitor visitor); - - - - - - MyLife - - Β«abstractΒ» - Asset - - - # String assetId; - - # Date createdDate; - - # Priority priority; - - - - - + String getAssetId(); - - + Date getCreatedDate(); - - + Priority getPriority(); - - + void accept(MyLife.IMyLifeVisitor visitor); - - - - - - MyLife - - - Employee - - - # String employeeId; - - # double salary; - - # Status employmentStatus; - - # List<Priority>responsibilities; - - - - - + String getEmployeeId(); - - + double getSalary(); - - + Status getEmploymentStatus(); - - + List<Priority>getResponsibilities(); - - + boolean containsResponsibilities(Object element); - - + boolean containsAllResponsibilities(java.util.Collection<?>collection); - - + boolean isEmptyResponsibilities(); - - + java.util.Iterator<Priority>iteratorResponsibilities(); - - + int sizeResponsibilities(); - - + Priority []toArrayResponsibilities(Priority []array); - - + Object []toArrayResponsibilities(); - - + java.util.Spliterator<Priority>spliteratorResponsibilities(); - - + java.util.stream.Stream<Priority>streamResponsibilities(); - - + java.util.stream.Stream<Priority>parallelStreamResponsibilities(); - - + boolean equalsResponsibilities(Object o); - - + int hashCodeResponsibilities(); - - + Priority getResponsibilities(int index); - - + int indexOfResponsibilities(Object element); - - + int lastIndexOfResponsibilities(Object element); - - + java.util.ListIterator<Priority>listIteratorResponsibilities(); - - + java.util.ListIterator<Priority>listIteratorResponsibilities(int index); - - + java.util.List<Priority>subListResponsibilities(int start,int end); - - + void accept(MyLife.IMyLifeVisitor visitor); - - - - - - MyLife - - - Project - - - # String projectName; - - # Date deadline; - - # List<String>milestones; - - - - - + String getProjectName(); - - + Date getDeadline(); - - + List<String>getMilestones(); - - + boolean containsMilestones(Object element); - - + boolean containsAllMilestones(java.util.Collection<?>collection); - - + boolean isEmptyMilestones(); - - + java.util.Iterator<String>iteratorMilestones(); - - + int sizeMilestones(); - - + String []toArrayMilestones(String []array); - - + Object []toArrayMilestones(); - - + java.util.Spliterator<String>spliteratorMilestones(); - - + java.util.stream.Stream<String>streamMilestones(); - - + java.util.stream.Stream<String>parallelStreamMilestones(); - - + boolean equalsMilestones(Object o); - - + int hashCodeMilestones(); - - + String getMilestones(int index); - - + int indexOfMilestones(Object element); - - + int lastIndexOfMilestones(Object element); - - + java.util.ListIterator<String>listIteratorMilestones(); - - + java.util.ListIterator<String>listIteratorMilestones(int index); - - + java.util.List<String>subListMilestones(int start,int end); - - + void accept(MyLife.IMyLifeVisitor visitor); - - - - - - MyLife - - - Task - - - # String taskName; - - # String description; - - # Status taskStatus; - - - - - + String getTaskName(); - - + String getDescription(); - - + Status getTaskStatus(); - - + void accept(MyLife.IMyLifeVisitor visitor); - - - - - - MyLife - - - Team - - - # String teamName; - - # int teamSize; - - # List<String>teamMembers; - - - - - + String getTeamName(); - - + int getTeamSize(); - - + List<String>getTeamMembers(); - - + boolean containsTeamMembers(Object element); - - + boolean containsAllTeamMembers(java.util.Collection<?>collection); - - + boolean isEmptyTeamMembers(); - - + java.util.Iterator<String>iteratorTeamMembers(); - - + int sizeTeamMembers(); - - + String []toArrayTeamMembers(String []array); - - + Object []toArrayTeamMembers(); - - + java.util.Spliterator<String>spliteratorTeamMembers(); - - + java.util.stream.Stream<String>streamTeamMembers(); - - + java.util.stream.Stream<String>parallelStreamTeamMembers(); - - + boolean equalsTeamMembers(Object o); - - + int hashCodeTeamMembers(); - - + String getTeamMembers(int index); - - + int indexOfTeamMembers(Object element); - - + int lastIndexOfTeamMembers(Object element); - - + java.util.ListIterator<String>listIteratorTeamMembers(); - - + java.util.ListIterator<String>listIteratorTeamMembers(int index); - - + java.util.List<String>subListTeamMembers(int start,int end); - - + void accept(MyLife.IMyLifeVisitor visitor); - - - - - - MyLife - - - Department - - - # String deptName; - - # String location; - - - - - + String getDeptName(); - - + String getLocation(); - - + void accept(MyLife.IMyLifeVisitor visitor); - - - - - - MyLife - - Β«interfaceΒ» - IMyLifeVisitor - - - - - + abstract void visit(Person node); - - + abstract void visit(Asset node); - - + abstract void visit(Employee node); - - + abstract void visit(Project node); - - + abstract void visit(Task node); - - + abstract void visit(Team node); - - + abstract void visit(Department node); - - - - - - MyLife - - - MyLifeVisitorImplementation - - - # Collection<Object>traversedElements; - - - - - + void visit(Person node); - - + void visit(Asset node); - - + void visit(Employee node); - - + void visit(Project node); - - + void visit(Task node); - - + void visit(Team node); - - + void visit(Department node); - - - - - - CD - - - diff --git a/docs/MyLifeOnlyWithAbstractMethodSignatures.cd b/docs/MyLifeOnlyWithAbstractMethodSignatures.cd deleted file mode 100644 index 39fae065b..000000000 --- a/docs/MyLifeOnlyWithAbstractMethodSignatures.cd +++ /dev/null @@ -1,79 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -import java.lang.String; -import java.util.List; -import java.util.Date; -import java.util.*; -public classdiagram MyLife { - package MyLife { - // ===== Enums ===== - public enum Status { - ACTIVE,INACTIVE,PAUSED; - - } - public enum Priority { - LOW,MEDIUM,HIGH,CRITICAL; - - } - public enum Role { - MANAGER,DEVELOPER,DESIGNER,ANALYST; - - } - // ===== Abstract Base Classes ===== - public abstract class Person { - public String name; - public Date birthDate; - public String email; - - } - public abstract class Asset { - public String assetId; - public Date createdDate; - public Priority priority; - - } - // ===== Concrete Classes (with inheritance) ===== - public class Employee extends Person { - public String employeeId; - public double salary; - public Status employmentStatus; - public Listresponsibilities; - - } - public class Project extends Asset { - public String projectName; - public Date deadline; - public Listmilestones; - - } - public class Task extends Asset { - public String taskName; - public String description; - public Status taskStatus; - - } - public class Team { - public String teamName; - public int teamSize; - public ListteamMembers; - - } - public class Department { - public String deptName; - public String location; - - } - // ===== Associations (Class-to-Class) ===== - public association public [1..*]Employee(works_in)--(has_members)Department[0..*]public; - public association public [1..*]Department(manages)--(assigned_to)Project[0..*]public; - public association public[0..*]Employee(works_on)--(lead_by)Project [1]public; - public association public [1..*]Team(contains)--(belongs_to)Employee[0..*]public; - public association public [1..*]Project(includes)--(part_of)Task[0..*]public; - public association public [1..*]Department(organizes)--(team)Team[0..*]public; - public association public [1..*]Employee(reports_to)--(role)Role[0..*]public; - // ===== Compositions ===== - public composition public [1]Project(project)--(task)Task [1..*]public; - public composition public [1]Department(department)--(team)Team [1..*]public; - - } - -} diff --git a/docs/MyLifeOnlyWithAbstractMethodSignatures.svg b/docs/MyLifeOnlyWithAbstractMethodSignatures.svg deleted file mode 100644 index 9ec00d981..000000000 --- a/docs/MyLifeOnlyWithAbstractMethodSignatures.svg +++ /dev/null @@ -1,587 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - works_in - 1..* - - - - - - - - works_in - - - - - - - has_members - 0..* - - - - - - - - has_members - - - - - - - - - - - - - manages - 1..* - - - - - - - - manages - - - - - - - assigned_to - 0..* - - - - - - - - assigned_to - - - - - - - - - - - - - works_on - 0..* - - - - - - - - works_on - - - - - - - lead_by - 1 - - - - - - - - lead_by - - - - - - - - - - - - - contains - 1..* - - - - - - - - contains - - - - - - - belongs_to - 0..* - - - - - - - - belongs_to - - - - - - - - - - - - - includes - 1..* - - - - - - - - includes - - - - - - - part_of - 0..* - - - - - - - - part_of - - - - - - - - - - - - - organizes - 1..* - - - - - - - - organizes - - - - - - - team - 0..* - - - - - - - - team - - - - - - - - - - - - - reports_to - 1..* - - - - - - - - reports_to - - - - - - - role - 0..* - - - - - - - - role - - - - - - - - - - - - - project - - - - - - - - - project - - - - - - - task - 1..* - - - - - - - - task - - - - - - - - - - - - - department - - - - - - - - - department - - - - - - - team - 1..* - - - - - - - - team - - - - - - MyLife - - Β«enumΒ» - Status - - - ACTIVE - INACTIVE - PAUSED - - - - - - - - - MyLife - - Β«enumΒ» - Priority - - - LOW - MEDIUM - HIGH - CRITICAL - - - - - - - - - MyLife - - Β«enumΒ» - Role - - - MANAGER - DEVELOPER - DESIGNER - ANALYST - - - - - - - - - MyLife - - Β«abstractΒ» - Person - - - + String name; - - + Date birthDate; - - + String email; - - - - - - - - MyLife - - Β«abstractΒ» - Asset - - - + String assetId; - - + Date createdDate; - - + Priority priority; - - - - - - - - MyLife - - - Employee - - - + String employeeId; - - + double salary; - - + Status employmentStatus; - - + List<Priority>responsibilities; - - - - - - - - MyLife - - - Project - - - + String projectName; - - + Date deadline; - - + List<String>milestones; - - - - - - - - MyLife - - - Task - - - + String taskName; - - + String description; - - + Status taskStatus; - - - - - - - - MyLife - - - Team - - - + String teamName; - - + int teamSize; - - + List<String>teamMembers; - - - - - - - - MyLife - - - Department - - - + String deptName; - - + String location; - - - - - - - - CD - - - diff --git a/docs/myOrganizer/cds/MyOrganizer.cd b/docs/myOrganizer/cds/MyOrganizer.cd new file mode 100644 index 000000000..d5d9dcad4 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizer.cd @@ -0,0 +1,30 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; + +classdiagram MyOrganizer { + + enum Status { PROCESSING, DONE, OPEN; } + + abstract class Asset { + void process(); + } + + class Task extends Asset { + private String taskName; + protected Status taskStatus; + void process(); + } + + class Project extends Asset { + public String projectName; + double budget; + void process(); + } + + class Day { + Date date; + } + + association [1] Day (day) -> (tasks) Task [1]; + association [*] Task (tasks) <-> (project) Project [1]; +} \ No newline at end of file diff --git a/docs/myOrganizer/cds/MyOrganizerNoDecorators.cd b/docs/myOrganizer/cds/MyOrganizerNoDecorators.cd new file mode 100644 index 000000000..f0e577bf8 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerNoDecorators.cd @@ -0,0 +1,38 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public void process(); + + } + public class Task extends Asset { + private String taskName; + protected Status taskStatus; + public void process(); + public MyOrganizer.Project project; + + } + public class Project extends Asset { + public String projectName; + public double budget; + public void process(); + public Settasks; + + } + public class Day { + public Date date; + public MyOrganizer.Task tasks; + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd b/docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd new file mode 100644 index 000000000..bffff32ca --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd @@ -0,0 +1,87 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public void process(); + + } + public class Task extends Asset { + private String taskName; + protected Status taskStatus; + public void process(); + public MyOrganizer.Project project; + + } + public class Project extends Asset { + public String projectName; + public double budget; + public void process(); + public Settasks; + + } + public class Day { + public Date date; + public MyOrganizer.Task tasks; + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + public abstract class AssetBuilder { + protected AssetBuilder realBuilder; + public AssetBuilder(); + private boolean isValid(); + public Asset build(); + public Asset unsafeBuild(); + + } + public class TaskBuilder { + protected TaskBuilder realBuilder; + public TaskBuilder(); + private boolean isValid(); + public Task build(); + public Task unsafeBuild(); + protected String taskName; + protected Status taskStatus; + protected MyOrganizer.Project project; + public TaskBuilder setTaskName(String taskName); + public TaskBuilder setTaskStatus(Status taskStatus); + public TaskBuilder setProject(MyOrganizer.Project project); + + } + public class ProjectBuilder { + protected ProjectBuilder realBuilder; + public ProjectBuilder(); + private boolean isValid(); + public Project build(); + public Project unsafeBuild(); + protected String projectName; + protected double budget; + protected Settasks; + public ProjectBuilder setProjectName(String projectName); + public ProjectBuilder setBudget(double budget); + public ProjectBuilder setTasks(Settasks); + public ProjectBuilder setTasksAbsent(); + + } + public class DayBuilder { + protected DayBuilder realBuilder; + public DayBuilder(); + private boolean isValid(); + public Day build(); + public Day unsafeBuild(); + protected Date date; + protected MyOrganizer.Task tasks; + public DayBuilder setDate(Date date); + public DayBuilder setTasks(MyOrganizer.Task tasks); + + } + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd b/docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd new file mode 100644 index 000000000..4823ccc52 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd @@ -0,0 +1,39 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public void process(); + + } + public class Task extends Asset { + private String taskName; + protected Status taskStatus; + public void process(); + public MyOrganizer.Project project; + + } + public class Project extends Asset { + public String projectName; + public double budget; + public void process(); + public Settasks; + public Project(); + + } + public class Day { + public Date date; + public MyOrganizer.Task tasks; + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd b/docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd new file mode 100644 index 000000000..aafe51fc3 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd @@ -0,0 +1,58 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public void process(); + + } + public class Task extends Asset { + protected String taskName; + protected Status taskStatus; + public void process(); + protected MyOrganizer.Project project; + private String getTaskName(); + protected Status getTaskStatus(); + public MyOrganizer.Project getProject(); + + } + public class Project extends Asset { + protected String projectName; + protected double budget; + public void process(); + protected Settasks; + public String getProjectName(); + public double getBudget(); + public SetgetTasks(); + public boolean containsTasks(Object element); + public boolean containsAllTasks(java.util.Collectioncollection); + public boolean isEmptyTasks(); + public java.util.IteratoriteratorTasks(); + public int sizeTasks(); + public MyOrganizer.Task []toArrayTasks(MyOrganizer.Task []array); + public Object []toArrayTasks(); + public java.util.SpliteratorspliteratorTasks(); + public java.util.stream.StreamstreamTasks(); + public java.util.stream.StreamparallelStreamTasks(); + public boolean equalsTasks(Object o); + public int hashCodeTasks(); + + } + public class Day { + protected Date date; + protected MyOrganizer.Task tasks; + public Date getDate(); + public MyOrganizer.Task getTasks(); + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd b/docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd new file mode 100644 index 000000000..99ed5b2f4 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd @@ -0,0 +1,50 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public void process(); + + } + public class Task extends Asset { + protected String taskName; + protected Status taskStatus; + public void process(); + protected MyOrganizer.Project project; + private void setTaskName(String taskName); + protected void setTaskStatus(Status taskStatus); + public void setProject(MyOrganizer.Project project); + public void setProjectLocal(MyOrganizer.Project project); + + } + public class Project extends Asset { + protected String projectName; + protected double budget; + public void process(); + protected Settasks; + public void setProjectName(String projectName); + public void setBudget(double budget); + public boolean addTasks(MyOrganizer.Task tasks); + public boolean removeTasks(MyOrganizer.Task tasks); + public boolean addTasksLocal(MyOrganizer.Task tasks); + public boolean removeTasksLocal(MyOrganizer.Task tasks); + + } + public class Day { + protected Date date; + protected MyOrganizer.Task tasks; + public void setDate(Date date); + public void setTasks(MyOrganizer.Task tasks); + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd b/docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd new file mode 100644 index 000000000..ea665cc02 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd @@ -0,0 +1,88 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset implements de.monticore.cd.ICDObservable{ + public void process(); + protected ListobserverList; + public void addObserver(MyOrganizer.IAssetObserver observer); + public void removeObserver(MyOrganizer.IAssetObserver observer); + protected void notifyObservers(); + + } + public class Task extends Asset implements de.monticore.cd.ICDObservable{ + private String taskName; + protected Status taskStatus; + public void process(); + public MyOrganizer.Project project; + protected ListobserverList; + public void addObserver(MyOrganizer.ITaskObserver observer); + public void removeObserver(MyOrganizer.ITaskObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetTaskName(String ov); + protected void notifyObserversSetTaskStatus(Status ov); + protected void notifyObserversSetProject(MyOrganizer.Project ov); + + } + public class Project extends Asset implements de.monticore.cd.ICDObservable{ + public String projectName; + public double budget; + public void process(); + public Settasks; + protected ListobserverList; + public void addObserver(MyOrganizer.IProjectObserver observer); + public void removeObserver(MyOrganizer.IProjectObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetProjectName(String ov); + protected void notifyObserversSetBudget(double ov); + protected void notifyObserversAddTasks(MyOrganizer.Task newElem); + protected void notifyObserversRemoveTasks(MyOrganizer.Task elem); + + } + public class Day implements de.monticore.cd.ICDObservable{ + public Date date; + public MyOrganizer.Task tasks; + protected ListobserverList; + public void addObserver(MyOrganizer.IDayObserver observer); + public void removeObserver(MyOrganizer.IDayObserver observer); + protected void notifyObservers(); + protected void notifyObserversSetDate(Date ov); + protected void notifyObserversSetTasks(MyOrganizer.Task ov); + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + public interface IAssetObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Asset clazz); + + } + public interface ITaskObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Task clazz); + public void notifyUpdateSetTaskName(Task clazz,String ov); + public void notifyUpdateSetTaskStatus(Task clazz,Status ov); + public void notifyUpdateSetProject(Task clazz,MyOrganizer.Project ov); + + } + public interface IProjectObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Project clazz); + public void notifyUpdateSetProjectName(Project clazz,String ov); + public void notifyUpdateSetBudget(Project clazz,double ov); + public void notifyUpdateAddTasks(Project clazz,MyOrganizer.Task newElem); + public void notifyUpdateRemoveTasks(Project clazz,MyOrganizer.Task elem); + + } + public interface IDayObserver extends de.monticore.cd.ICDObserver{ + public void notifyUpdate(Day clazz); + public void notifyUpdateSetDate(Day clazz,Date ov); + public void notifyUpdateSetTasks(Day clazz,MyOrganizer.Task ov); + + } + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlySetter.cd b/docs/myOrganizer/cds/MyOrganizerOnlySetter.cd new file mode 100644 index 000000000..0c16b757a --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlySetter.cd @@ -0,0 +1,47 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public void process(); + + } + public class Task extends Asset { + protected String taskName; + protected Status taskStatus; + public void process(); + protected MyOrganizer.Project project; + private void setTaskName(String taskName); + protected void setTaskStatus(Status taskStatus); + public void setProject(MyOrganizer.Project project); + + } + public class Project extends Asset { + protected String projectName; + protected double budget; + public void process(); + protected Settasks; + public void setProjectName(String projectName); + public void setBudget(double budget); + public boolean addTasks(MyOrganizer.Task tasks); + public boolean removeTasks(MyOrganizer.Task tasks); + + } + public class Day { + protected Date date; + protected MyOrganizer.Task tasks; + public void setDate(Date date); + public void setTasks(MyOrganizer.Task tasks); + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd b/docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd new file mode 100644 index 000000000..37f8f3490 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd @@ -0,0 +1,77 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public void process(); + public void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + } + public class Task extends Asset { + protected String taskName; + protected Status taskStatus; + public void process(); + protected MyOrganizer.Project project; + private String getTaskName(); + protected Status getTaskStatus(); + public MyOrganizer.Project getProject(); + public void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + } + public class Project extends Asset { + protected String projectName; + protected double budget; + public void process(); + protected Settasks; + public String getProjectName(); + public double getBudget(); + public SetgetTasks(); + public boolean containsTasks(Object element); + public boolean containsAllTasks(java.util.Collectioncollection); + public boolean isEmptyTasks(); + public java.util.IteratoriteratorTasks(); + public int sizeTasks(); + public MyOrganizer.Task []toArrayTasks(MyOrganizer.Task []array); + public Object []toArrayTasks(); + public java.util.SpliteratorspliteratorTasks(); + public java.util.stream.StreamstreamTasks(); + public java.util.stream.StreamparallelStreamTasks(); + public boolean equalsTasks(Object o); + public int hashCodeTasks(); + public void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + } + public class Day { + protected Date date; + protected MyOrganizer.Task tasks; + public Date getDate(); + public MyOrganizer.Task getTasks(); + public void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + public interface IMyOrganizerVisitor { + public abstract void visit(Asset node); + public abstract void visit(Task node); + public abstract void visit(Project node); + public abstract void visit(Day node); + + } + public class MyOrganizerVisitorImplementation implements IMyOrganizerVisitor { + protected CollectiontraversedElements; + public void visit(Asset node); + public void visit(Task node); + public void visit(Project node); + public void visit(Day node); + + } + + } + +} diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd b/docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd new file mode 100644 index 000000000..be6ffbb26 --- /dev/null +++ b/docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd @@ -0,0 +1,38 @@ +/* (c) https://github.com/MontiCore/monticore */ +import java.util.Date; +import java.util.*; +public classdiagram MyOrganizer { + package MyOrganizer { + public enum Status { + PROCESSING,DONE,OPEN; + + } + public abstract class Asset { + public abstract void process(); + + } + public abstract class Task extends Asset { + private String taskName; + protected Status taskStatus; + public abstract void process(); + public MyOrganizer.Project project; + + } + public abstract class Project extends Asset { + public String projectName; + public double budget; + public abstract void process(); + public Settasks; + + } + public class Day { + public Date date; + public MyOrganizer.Task tasks; + + } + public association public [1]Day(day)->(tasks)Task [1]public; + public association public[*]Task(tasks)<->(project)Project [1]public; + + } + +} diff --git a/docs/myOrganizer/img/MyOrganizer.svg b/docs/myOrganizer/img/MyOrganizer.svg new file mode 100644 index 000000000..46b7df356 --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizer.svg @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + + + Β«abstractΒ» + Asset + + + + + void process(); + + + + + + + + + Task + + + - String taskName; + + # Status taskStatus; + + + + + void process(); + + + + + + + + + Project + + + + String projectName; + + double budget; + + + + + void process(); + + + + + + + + + Day + + + Date date; + + + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerNoDecorators.svg b/docs/myOrganizer/img/MyOrganizerNoDecorators.svg new file mode 100644 index 000000000..1e6eedfc6 --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerNoDecorators.svg @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + void process(); + + + + + + MyOrganizer + + + Task + + + - String taskName; + + # Status taskStatus; + + + MyOrganizer.Project project; + + + + + + void process(); + + + + + + MyOrganizer + + + Project + + + + String projectName; + + + double budget; + + + Set<MyOrganizer.Task>tasks; + + + + + + void process(); + + + + + + MyOrganizer + + + Day + + + + Date date; + + + MyOrganizer.Task tasks; + + + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlyBuilders.svg b/docs/myOrganizer/img/MyOrganizerOnlyBuilders.svg new file mode 100644 index 000000000..0d1fcc91a --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlyBuilders.svg @@ -0,0 +1,336 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + void process(); + + + + + + MyOrganizer + + + Task + + + - String taskName; + + # Status taskStatus; + + + MyOrganizer.Project project; + + + + + + void process(); + + + + + + MyOrganizer + + + Project + + + + String projectName; + + + double budget; + + + Set<MyOrganizer.Task>tasks; + + + + + + void process(); + + + + + + MyOrganizer + + + Day + + + + Date date; + + + MyOrganizer.Task tasks; + + + + + + + + MyOrganizer + + Β«abstractΒ» + AssetBuilder + + + # AssetBuilder realBuilder; + + + + + - boolean isValid(); + + + Asset build(); + + + Asset unsafeBuild(); + + + + + + MyOrganizer + + + TaskBuilder + + + # TaskBuilder realBuilder; + + # String taskName; + + # Status taskStatus; + + # MyOrganizer.Project project; + + + + + - boolean isValid(); + + + Task build(); + + + Task unsafeBuild(); + + + TaskBuilder setTaskName(String taskName); + + + TaskBuilder setTaskStatus(Status taskStatus); + + + TaskBuilder setProject(MyOrganizer.Project project); + + + + + + MyOrganizer + + + ProjectBuilder + + + # ProjectBuilder realBuilder; + + # String projectName; + + # double budget; + + # Set<MyOrganizer.Task>tasks; + + + + + - boolean isValid(); + + + Project build(); + + + Project unsafeBuild(); + + + ProjectBuilder setProjectName(String projectName); + + + ProjectBuilder setBudget(double budget); + + + ProjectBuilder setTasks(Set<MyOrganizer.Task>tasks); + + + ProjectBuilder setTasksAbsent(); + + + + + + MyOrganizer + + + DayBuilder + + + # DayBuilder realBuilder; + + # Date date; + + # MyOrganizer.Task tasks; + + + + + - boolean isValid(); + + + Day build(); + + + Day unsafeBuild(); + + + DayBuilder setDate(Date date); + + + DayBuilder setTasks(MyOrganizer.Task tasks); + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlyDefaultsForCardinalityAttrs.svg b/docs/myOrganizer/img/MyOrganizerOnlyDefaultsForCardinalityAttrs.svg new file mode 100644 index 000000000..1e6eedfc6 --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlyDefaultsForCardinalityAttrs.svg @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + void process(); + + + + + + MyOrganizer + + + Task + + + - String taskName; + + # Status taskStatus; + + + MyOrganizer.Project project; + + + + + + void process(); + + + + + + MyOrganizer + + + Project + + + + String projectName; + + + double budget; + + + Set<MyOrganizer.Task>tasks; + + + + + + void process(); + + + + + + MyOrganizer + + + Day + + + + Date date; + + + MyOrganizer.Task tasks; + + + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlyGetter.svg b/docs/myOrganizer/img/MyOrganizerOnlyGetter.svg new file mode 100644 index 000000000..a890c75e7 --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlyGetter.svg @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + void process(); + + + + + + MyOrganizer + + + Task + + + # String taskName; + + # Status taskStatus; + + # MyOrganizer.Project project; + + + + + + void process(); + + - String getTaskName(); + + # Status getTaskStatus(); + + + MyOrganizer.Project getProject(); + + + + + + MyOrganizer + + + Project + + + # String projectName; + + # double budget; + + # Set<MyOrganizer.Task>tasks; + + + + + + void process(); + + + String getProjectName(); + + + double getBudget(); + + + Set<MyOrganizer.Task>getTasks(); + + + boolean containsTasks(Object element); + + + boolean containsAllTasks(java.util.Collection<?>collection); + + + boolean isEmptyTasks(); + + + java.util.Iterator<MyOrganizer.Task>iteratorTasks(); + + + int sizeTasks(); + + + MyOrganizer.Task []toArrayTasks(MyOrganizer.Task []array); + + + Object []toArrayTasks(); + + + java.util.Spliterator<MyOrganizer.Task>spliteratorTasks(); + + + java.util.stream.Stream<MyOrganizer.Task>streamTasks(); + + + java.util.stream.Stream<MyOrganizer.Task>parallelStreamTasks(); + + + boolean equalsTasks(Object o); + + + int hashCodeTasks(); + + + + + + MyOrganizer + + + Day + + + # Date date; + + # MyOrganizer.Task tasks; + + + + + + Date getDate(); + + + MyOrganizer.Task getTasks(); + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlyNavigableSetter.svg b/docs/myOrganizer/img/MyOrganizerOnlyNavigableSetter.svg new file mode 100644 index 000000000..9277d3ddf --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlyNavigableSetter.svg @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + void process(); + + + + + + MyOrganizer + + + Task + + + # String taskName; + + # Status taskStatus; + + # MyOrganizer.Project project; + + + + + + void process(); + + - void setTaskName(String taskName); + + # void setTaskStatus(Status taskStatus); + + + void setProject(MyOrganizer.Project project); + + + void setProjectLocal(MyOrganizer.Project project); + + + + + + MyOrganizer + + + Project + + + # String projectName; + + # double budget; + + # Set<MyOrganizer.Task>tasks; + + + + + + void process(); + + + void setProjectName(String projectName); + + + void setBudget(double budget); + + + boolean addTasks(MyOrganizer.Task tasks); + + + boolean removeTasks(MyOrganizer.Task tasks); + + + boolean addTasksLocal(MyOrganizer.Task tasks); + + + boolean removeTasksLocal(MyOrganizer.Task tasks); + + + + + + MyOrganizer + + + Day + + + # Date date; + + # MyOrganizer.Task tasks; + + + + + + void setDate(Date date); + + + void setTasks(MyOrganizer.Task tasks); + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlyObservers.svg b/docs/myOrganizer/img/MyOrganizerOnlyObservers.svg new file mode 100644 index 000000000..d86283bc3 --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlyObservers.svg @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + # List<MyOrganizer.IAssetObserver>observerList; + + + + + + void process(); + + + void addObserver(MyOrganizer.IAssetObserver observer); + + + void removeObserver(MyOrganizer.IAssetObserver observer); + + # void notifyObservers(); + + + + + + MyOrganizer + + + Task + + + - String taskName; + + # Status taskStatus; + + + MyOrganizer.Project project; + + # List<MyOrganizer.ITaskObserver>observerList; + + + + + + void process(); + + + void addObserver(MyOrganizer.ITaskObserver observer); + + + void removeObserver(MyOrganizer.ITaskObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetTaskName(String ov); + + # void notifyObserversSetTaskStatus(Status ov); + + # void notifyObserversSetProject(MyOrganizer.Project ov); + + + + + + MyOrganizer + + + Project + + + + String projectName; + + + double budget; + + + Set<MyOrganizer.Task>tasks; + + # List<MyOrganizer.IProjectObserver>observerList; + + + + + + void process(); + + + void addObserver(MyOrganizer.IProjectObserver observer); + + + void removeObserver(MyOrganizer.IProjectObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetProjectName(String ov); + + # void notifyObserversSetBudget(double ov); + + # void notifyObserversAddTasks(MyOrganizer.Task newElem); + + # void notifyObserversRemoveTasks(MyOrganizer.Task elem); + + + + + + MyOrganizer + + + Day + + + + Date date; + + + MyOrganizer.Task tasks; + + # List<MyOrganizer.IDayObserver>observerList; + + + + + + void addObserver(MyOrganizer.IDayObserver observer); + + + void removeObserver(MyOrganizer.IDayObserver observer); + + # void notifyObservers(); + + # void notifyObserversSetDate(Date ov); + + # void notifyObserversSetTasks(MyOrganizer.Task ov); + + + + + + MyOrganizer + + Β«interfaceΒ» + IAssetObserver + + + + + + void notifyUpdate(Asset clazz); + + + + + + MyOrganizer + + Β«interfaceΒ» + ITaskObserver + + + + + + void notifyUpdate(Task clazz); + + + void notifyUpdateSetTaskName(Task clazz,String ov); + + + void notifyUpdateSetTaskStatus(Task clazz,Status ov); + + + void notifyUpdateSetProject(Task clazz,MyOrganizer.Project ov); + + + + + + MyOrganizer + + Β«interfaceΒ» + IProjectObserver + + + + + + void notifyUpdate(Project clazz); + + + void notifyUpdateSetProjectName(Project clazz,String ov); + + + void notifyUpdateSetBudget(Project clazz,double ov); + + + void notifyUpdateAddTasks(Project clazz,MyOrganizer.Task newElem); + + + void notifyUpdateRemoveTasks(Project clazz,MyOrganizer.Task elem); + + + + + + MyOrganizer + + Β«interfaceΒ» + IDayObserver + + + + + + void notifyUpdate(Day clazz); + + + void notifyUpdateSetDate(Day clazz,Date ov); + + + void notifyUpdateSetTasks(Day clazz,MyOrganizer.Task ov); + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlySetter.svg b/docs/myOrganizer/img/MyOrganizerOnlySetter.svg new file mode 100644 index 000000000..eb5872ff8 --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlySetter.svg @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + void process(); + + + + + + MyOrganizer + + + Task + + + # String taskName; + + # Status taskStatus; + + # MyOrganizer.Project project; + + + + + + void process(); + + - void setTaskName(String taskName); + + # void setTaskStatus(Status taskStatus); + + + void setProject(MyOrganizer.Project project); + + + + + + MyOrganizer + + + Project + + + # String projectName; + + # double budget; + + # Set<MyOrganizer.Task>tasks; + + + + + + void process(); + + + void setProjectName(String projectName); + + + void setBudget(double budget); + + + boolean addTasks(MyOrganizer.Task tasks); + + + boolean removeTasks(MyOrganizer.Task tasks); + + + + + + MyOrganizer + + + Day + + + # Date date; + + # MyOrganizer.Task tasks; + + + + + + void setDate(Date date); + + + void setTasks(MyOrganizer.Task tasks); + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlyVisitors.svg b/docs/myOrganizer/img/MyOrganizerOnlyVisitors.svg new file mode 100644 index 000000000..e14ee0420 --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlyVisitors.svg @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + void process(); + + + void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + + + + + MyOrganizer + + + Task + + + # String taskName; + + # Status taskStatus; + + # MyOrganizer.Project project; + + + + + + void process(); + + - String getTaskName(); + + # Status getTaskStatus(); + + + MyOrganizer.Project getProject(); + + + void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + + + + + MyOrganizer + + + Project + + + # String projectName; + + # double budget; + + # Set<MyOrganizer.Task>tasks; + + + + + + void process(); + + + String getProjectName(); + + + double getBudget(); + + + Set<MyOrganizer.Task>getTasks(); + + + boolean containsTasks(Object element); + + + boolean containsAllTasks(java.util.Collection<?>collection); + + + boolean isEmptyTasks(); + + + java.util.Iterator<MyOrganizer.Task>iteratorTasks(); + + + int sizeTasks(); + + + MyOrganizer.Task []toArrayTasks(MyOrganizer.Task []array); + + + Object []toArrayTasks(); + + + java.util.Spliterator<MyOrganizer.Task>spliteratorTasks(); + + + java.util.stream.Stream<MyOrganizer.Task>streamTasks(); + + + java.util.stream.Stream<MyOrganizer.Task>parallelStreamTasks(); + + + boolean equalsTasks(Object o); + + + int hashCodeTasks(); + + + void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + + + + + MyOrganizer + + + Day + + + # Date date; + + # MyOrganizer.Task tasks; + + + + + + Date getDate(); + + + MyOrganizer.Task getTasks(); + + + void accept(MyOrganizer.IMyOrganizerVisitor visitor); + + + + + + MyOrganizer + + Β«interfaceΒ» + IMyOrganizerVisitor + + + + + + abstract void visit(Asset node); + + + abstract void visit(Task node); + + + abstract void visit(Project node); + + + abstract void visit(Day node); + + + + + + MyOrganizer + + + MyOrganizerVisitorImplementation + + + # Collection<Object>traversedElements; + + + + + + void visit(Asset node); + + + void visit(Task node); + + + void visit(Project node); + + + void visit(Day node); + + + + + + CD + + + diff --git a/docs/myOrganizer/img/MyOrganizerOnlyWithAbstractMethodSignatures.svg b/docs/myOrganizer/img/MyOrganizerOnlyWithAbstractMethodSignatures.svg new file mode 100644 index 000000000..514b03c6e --- /dev/null +++ b/docs/myOrganizer/img/MyOrganizerOnlyWithAbstractMethodSignatures.svg @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + day + 1 + + + + + + + + day + + + + + + + tasks + 1 + + + + + + + + tasks + + + + + + + + + + + + + tasks + * + + + + + + + + tasks + + + + + + + project + 1 + + + + + + + + project + + + + + + MyOrganizer + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + + + + + + + + MyOrganizer + + Β«abstractΒ» + Asset + + + + + + abstract void process(); + + + + + + MyOrganizer + + Β«abstractΒ» + Task + + + - String taskName; + + # Status taskStatus; + + + MyOrganizer.Project project; + + + + + + abstract void process(); + + + + + + MyOrganizer + + Β«abstractΒ» + Project + + + + String projectName; + + + double budget; + + + Set<MyOrganizer.Task>tasks; + + + + + + abstract void process(); + + + + + + MyOrganizer + + + Day + + + + Date date; + + + MyOrganizer.Task tasks; + + + + + + + + CD + + + From bb3c28ad7995f22d474c03fc38878c1257097645 Mon Sep 17 00:00:00 2001 From: Hendrik7889 <44064629+Hendrik7889@users.noreply.github.com> Date: Mon, 8 Jun 2026 18:04:20 +0200 Subject: [PATCH 05/14] add Decorator pages --- docs/GettingStarted.md | 240 +++++--------- docs/decorators/AbstractMethodDecorator.md | 36 ++ docs/decorators/BuilderDecorator.md | 61 ++++ .../decorators/CardinalityDefaultDecorator.md | 40 +++ docs/decorators/CopyDecorator.md | 56 ++++ docs/decorators/GetterDecorator.md | 87 +++++ docs/decorators/NavigableSetterDecorator.md | 94 ++++++ docs/decorators/ObserverDecorator.md | 44 +++ docs/decorators/SetterDecorator.md | 98 ++++++ docs/decorators/VisitorDecorator.md | 76 +++++ docs/myOrganizer/cds/MyOrganizer.cd | 9 +- .../cds/MyOrganizerNoDecorators.cd | 11 +- .../cds/MyOrganizerOnlyBuilders.cd | 21 +- ...rganizerOnlyDefaultsForCardinalityAttrs.cd | 12 +- docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd | 28 +- .../cds/MyOrganizerOnlyNavigableSetter.cd | 17 +- .../cds/MyOrganizerOnlyObservers.cd | 21 +- docs/myOrganizer/cds/MyOrganizerOnlySetter.cd | 17 +- .../cds/MyOrganizerOnlyVisitors.cd | 28 +- ...ganizerOnlyWithAbstractMethodSignatures.cd | 11 +- docs/myOrganizer/img/MyOrganizer.svg | 182 +++++------ .../img/MyOrganizerNoDecorators.svg | 188 +++++------ .../img/MyOrganizerOnlyBuilders.svg | 308 +++++++++--------- ...ganizerOnlyDefaultsForCardinalityAttrs.svg | 188 +++++------ .../myOrganizer/img/MyOrganizerOnlyGetter.svg | 246 +++++++------- .../img/MyOrganizerOnlyNavigableSetter.svg | 204 ++++++------ .../img/MyOrganizerOnlyObservers.svg | 302 ++++++++--------- .../myOrganizer/img/MyOrganizerOnlySetter.svg | 198 +++++------ .../img/MyOrganizerOnlyVisitors.svg | 188 ++++++----- ...anizerOnlyWithAbstractMethodSignatures.svg | 188 +++++------ 30 files changed, 1911 insertions(+), 1288 deletions(-) create mode 100644 docs/decorators/AbstractMethodDecorator.md create mode 100644 docs/decorators/BuilderDecorator.md create mode 100644 docs/decorators/CardinalityDefaultDecorator.md create mode 100644 docs/decorators/CopyDecorator.md create mode 100644 docs/decorators/GetterDecorator.md create mode 100644 docs/decorators/NavigableSetterDecorator.md create mode 100644 docs/decorators/ObserverDecorator.md create mode 100644 docs/decorators/SetterDecorator.md create mode 100644 docs/decorators/VisitorDecorator.md diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 00a8d568e..6eb247edb 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -102,7 +102,9 @@ extended with the addition of decorators. These decorators dictate what artifact are generated from the class diagram, or which should not be generated at all. ```cd4code +/* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; classdiagram MyOrganizer { @@ -113,14 +115,14 @@ classdiagram MyOrganizer { } class Task extends Asset { - String taskName; Status taskStatus; void process(); } class Project extends Asset { public String projectName; - double budget; + private Optional deadline; + protected double budget; void process(); } @@ -128,7 +130,7 @@ classdiagram MyOrganizer { Date date; } - association [1] Day (day) -> (tasks) Task [1]; + association [1] Day (day) -> (tasks) Task [*]; association [*] Task (tasks) <-> (project) Project [1]; } ``` @@ -139,12 +141,9 @@ It begins with the `classdiagram` keyword, followed by the name of the diagram, which must match the filename. In our example, the diagram is named `MyOrganizer` and its body is enclosed in curly braces `{ }`. -Class diagrams can have a package declaration and import statements to integrate external types. -If a class diagram defines a package, the package declaration must be the first statement in -the file and takes the form `package` *QualifiedName*, where `package` is a keyword and -*QualifiedName* is an arbitrary namespace. +Class diagrams can have import statements to integrate external types. Every import is of the form `import` *QualifiedName*. For instance, the `MyOrganizer` class diagram -uses `import java.util.Date;` to make the standard Java `Date` class available within the model. +uses `import java.util.Date;` and `import java.util.Optional;` to make the standard Java `Date` and `Optional` classes available within the model. Inside the class diagram, various object-oriented constructs can be defined, such as enumerations, classes, interfaces, and their relationships. The `MyOrganizer` diagram introduces the enumeration `Status` using @@ -156,8 +155,8 @@ Furthermore, the `extends` keyword is used to establish inheritance. In our exam as well, using the `interface` keyword, and classes can implement interfaces using the `implements` keyword. Classes typically contain attributes, which consist of a type and a name. The CD4Code -generator supports standard Java primitive types (like `double budget;`) , imported external types (like `Date date`), -and custom types like enums (`Status taskStatus`). Classes and interfaces can also define methods, such as `void process();`. +generator supports standard Java primitive types (like `double budget;`) , imported external types (like `Date date` and `Optional deadline`), +and custom types like enums (`Status taskStatus`). Classes and interfaces can also define methods, such as `void process();`. You can also define access modifiers like `public`, `private` and `protected`. Finally, the class diagram defines how these entities relate to one another using associations and compositions. While associations define relationships between two entities that simply know about each other, @@ -168,64 +167,100 @@ and navigation arrows (`<->` for bidirectional, `->` for directional, or `--` for unspecified). Relationships can also specify role names in parentheses to clarify the relationship's context, such as `(project)` and `(tasks)`. -### Default Configuration: CD2Poj -By default, the [CD2Pojo.ftl](../cdlang/src/main/resources/cd2java/init/CD2Pojo.ftl) template -is used by the generator. -It includes the following transformations: +## Decorators +At the very start of the CD4Code generator, the generator parses the class diagram DSL into the *CD4C Abstract Syntax Tree (AST)* +which represents the class diagram as an object tree. +Then the CD4Code generator applies the decorators to the AST. -* CD4CodeAfterParseTrafo: -* DefaultVisibilityPublicTrafo: absent visibility means *public* +Decorators are classes that can modify the AST by adding, removing, or changing elements and by adding template +hooks to objects of the AST. While the modifications on the AST can be visualized and seen directly, the template +hooks are only processed when the actual code generation takes place. +The CD4Code generator comes with a set of prewritten decorators which can be applied to the AST. In This chapter, we will +discuss the decorators in detail. + +The Basis of all Decorators is the `CopyDecorator` which is responsible for copying the original `AST` and doing +some basic transformations on it. After this the CD4Code generator will apply the remaining decorators to the AST. +As some Decorators dependent on other Decorators, all Decorators implement the +interface `IDecorator` which contains the method `getDependencies()` which returns a list of Decorators that must +be run before itself. For example, the VisitorDecorator depends on the GetterDecorator, +so the `getDependencies()` method returns `Collections.singletonList(GetterDecorator.class)`. Therefore, the +CD4Code generator checks the dependencies of the selected Decorators and runs them in the correct order. +If there is a circular dependency, the CD4Code generator throws an error and does not generate any code. + +```java +/** Extend {@link AbstractDecorator} for shared */ +public interface IDecorator extends IVisitor { + + /** + * Add your decorator-visitor to the given traverser + * + * @param traverser the traverser + */ + void addToTraverser(CD4CodeTraverser traverser); + + void init(DecoratorData util, Optional glexOpt); + + /** @return the list of decorators which MUST traverse the AST before */ + @SuppressWarnings("rawtypes") + default Iterable> getMustRunAfter() { + return Collections.singletonList(ICreator.class); + } + +} +``` +By default, the [CD2Pojo.ftl](../cdlang/src/main/resources/cd2java/init/CD2Pojo.ftl) template is being used by the CD4Code generator. It includes the following decorators: | Decorator | Description | To Enable | To Disable | |-----------------------------|--------------------------------------------------------------------|--------------------------|-------------------------------------------| -| CopyCreator | Include all elements of the original CD in the output | always | - | -| GetterDecorator | Add Getter Methods | 🟩 `<>` | `<>` | -| SetterDecorator | Add Setter Methods | 🟩 `<>` | `<>` | -| CardinalityDefaultDecorator | Optional and list attributes are initialized with an empty default | 🟩 | `<>` | -| NavigableSetterDecorator | Setters of bidirectional associations are also bidirectional | 🟩 `<>` | `<>` | -| AbstractMethodDecorator | Defined methods are made abstract | 🟩 `<>` | `<>` | -| BuilderDecorator | Add a builder class | 🟨 `<>` | `<>` | -| ObserverDecorator | Turn the class observable | 🟨 `<>` | `<>` | -| VisitorDecorator | Include a visitor | 🟨 `<>` | `<>` or `<>` | +| [CopyDecorator](decorators/CopyDecorator.md) | Include all elements of the original CD in the output | always | - | +| [GetterDecorator](decorators/GetterDecorator.md) | Add Getter Methods | 🟩 `<>` | `<>` | +| [SetterDecorator](decorators/SetterDecorator.md) | Add Setter Methods | 🟩 `<>` | `<>` | +| [CardinalityDefaultDecorator](decorators/CardinalityDefaultDecorator.md) | Optional and list attributes are initialized with an empty default | 🟩 | `<>` | +| [NavigableSetterDecorator](decorators/NavigableSetterDecorator.md) | Setters of bidirectional associations are also bidirectional | 🟩 `<>` | `<>` | +| [AbstractMethodDecorator](decorators/AbstractMethodDecorator.md) | Defined methods are made abstract | 🟩 `<>` | `<>` | +| [BuilderDecorator](decorators/BuilderDecorator.md) | Add a builder class | 🟨 `<>` | `<>` | +| [ObserverDecorator](decorators/ObserverDecorator.md) | Turn the class observable | 🟨 `<>` | `<>` | +| [VisitorDecorator](decorators/VisitorDecorator.md) | Include a visitor | 🟨 `<>` | `<>` or `<>` | In the default configuration, 🟩 means the decorator is applied unless disabled. 🟨 means the decorator is not applied unless enabled. +You can find a more detailed description of the decorators by clicking on the corresponding name. -This means by default that the CD4Code generator will generate getters and setters for all attributes. -Furthermore, it will initialize the cardinality of all optional attributes with an empty default value. Finally, the bidirectional associations between -`Project` and `Task` will be navigable in both directions, meaning that the generated setter methods +This means by default that the CD4Code generator will generate getters and setters for all attributes. +Furthermore, it will initialize the cardinality of all optional attributes with an empty default value. Finally, the bidirectional associations between +`Project` and `Task` will be navigable in both directions, meaning that the generated setter methods will also set the opposite side of the association by default. ### Configuring the CD4Code Generator -While the default `CD2Pojo` configuration is a great starting point, manually adding stereotypes -(like `<>` or `<>`) directly to every element in a `.cd` file can become -tedious and clutter the model. To solve this, the CD4Code Generator allows you to configure +While the default `CD2Pojo` configuration is a great starting point, manually adding stereotypes +(like `<>` or `<>`) directly to every element in a `.cd` file can become +tedious and clutter the model. To solve this, the CD4Code Generator allows you to configure decorators externally. Configuration can be applied at two different levels: -1. **Element-Level Configuration (Tagging):** You can target specific elements inside your class diagram - (such as a specific class, enum, or attribute) to explicitly enable or disable a decorator. - This uses a targeting syntax of `.:`. For example, targeting - `MyOrganizer.Day:noSetter` will prevent the generator from creating setter methods specifically for +1. **Element-Level Configuration (Tagging):** You can target specific elements inside your class diagram + (such as a specific class, enum, or attribute) to explicitly enable or disable a decorator. + This uses a targeting syntax of `.:`. For example, targeting + `MyOrganizer.Day:noSetter` will prevent the generator from creating setter methods specifically for the `Day` class. -2. **Global-Level Configuration (Templates):** If you need to fundamentally change the default behavior or - apply your own custom decorators across the entire build, you can supply a custom configuration template +2. **Global-Level Configuration (Templates):** If you need to fundamentally change the default behavior or + apply your own custom decorators across the entire build, you can supply a custom configuration template (e.g., a custom `.ftl` file) to replace the default `CD2Pojo` template. ### Applying Configurations -Depending on how you are running the CD4Code Generator, you can pass these configurations via the command line, +Depending on how you are running the CD4Code Generator, you can pass these configurations via the command line, your Gradle build script, or directly through the Java API. Select your environment below: === "CLI" - When running the CD4Code generator from the command line, you can pass element-level tags using the `-cliconfig` - parameter. Multiple configurations can be applied by repeating the argument. - +When running the CD4Code generator from the command line, you can pass element-level tags using the `-cliconfig` +parameter. Multiple configurations can be applied by repeating the argument. + For example, to disable getters and setters specifically for the `Day` class inside the `MyOrganizer` diagram, use the following command: @@ -241,9 +276,9 @@ your Gradle build script, or directly through the Java API. Select your environm ``` === "Gradle" - When using Gradle, element-level configurations can be added directly to the `options` list of the - `generateClassDiagrams` task. - +When using Gradle, element-level configurations can be added directly to the `options` list of the +`generateClassDiagrams` task. + ```groovy // build.gradle tasks.named("generateClassDiagrams") { @@ -263,123 +298,6 @@ your Gradle build script, or directly through the Java API. Select your environm } ``` -## Decorators -At the very start of the CD4Code generator, the generator parses the class diagram DSL into the *CD4C Abstract Syntax Tree (AST)* -which represents the class diagram as an object tree. -In a first step, the CD4Code generator uses the mandatory CopyDecorator to unify the *CD4C AST*. -It copies the parsed AST and unifies it by adding a package if no package exists. Furthermore, it adds the -attributes defined in the association and compositions to the respective classes. This means for cardinality `[*]` the -attribute is added as a Set and for cardinality `[1]` it is added as a single field, and for cardinality `[1..*]` it -is added as an Optional. -All unset visibilities of attributes, classes, interfaces, and enums are set to public. -Based on this unified AST, the CD4Code generator applies the other decorators which can be selected individually by the user. -In Figure 4.1 we can see the original class diagram and in Figure 4.2 the generated code. - -![Figure 4.1 The original class diagram](../myOrganizer/img/MyOrganizer.svg) -
Figure 4.1 The original class diagram
- -![Figure 4.2 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.2 The original class diagram after applying the CopyDecorator
- -=== "GetterDecorator" - The GetterDecorator adds getter methods to all attributes of the class diagram. - - ![Figure 4.3 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.13 The original class diagram
- - ![Figure 4.4 The original class diagram after applying the GetterDecorator](../myOrganizer/img/MyOrganizerOnlyGetter.svg) -
Figure 4.4 The original class diagram after applying the GetterDecorator
- -=== "SetterDecorator" - The SetterDecorator adds setter methods to all attributes of the class diagram. - - ![Figure 4.5 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.5 The original class diagram
- - ![Figure 4.6 The original class diagram after applying the SetterDecorator](../myOrganizer/img/MyOrganizerOnlySetter.svg) -
Figure 4.6 The original class diagram after applying the SetterDecorator
- -=== "CardinalitiesDefaultDecorator" - The CardinalitiesDefaultDecorator initiates Lists, Sets, and Optional attributes of the class diagram with an empty List, empty Set, or an empty Optional respectively. As the CopyDecorator always runs as the first Decorator and adds the attributes defined in the associations and compositions to the respective classes, the CardinalitiesDefaultDecorator also adds default values to these attributes. - - As cardinality is not specified in the class diagram, the CardinalitiesDefaultDecorator instead injects the initialization via a template hook. This template contains the specific java code which is then in the generation step checked and applied. - -=== "NavigableSetterDecorator" - The NavigableSetterDecorator adds setter methods to all navigable associations of the class diagram. - - ![Figure 4.9 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.9 The original class diagram
- - ![Figure 4.10 The original class diagram after applying the NavigableSetterDecorator](../myOrganizer/img/MyOrganizerOnlyNavigableSetter.svg) -
Figure 4.10 The original class diagram after applying the NavigableSetterDecorator
- -=== "AbstractMethodDecorator" - The AbstractMethodDecorator adds abstract methods to all methods of the class diagram. - - ![Figure 4.11 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.11 The original class diagram
- - ![Figure 4.12 The original class diagram after applying the AbstractMethodDecorator](../myOrganizer/img/MyOrganizerOnlyWithAbstractMethodSignatures.svg) -
Figure 4.12 The original class diagram after applying the AbstractMethodDecorator
- -=== "BuilderDecorator" - The BuilderDecorator adds a builder class to all classes of the class diagram. - - ![Figure 4.13 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.13 The original class diagram
- - ![Figure 4.14 The original class diagram after applying the BuilderDecorator](../myOrganizer/img/MyOrganizerOnlyBuilders.svg) -
Figure 4.14 The original class diagram after applying the BuilderDecorator
- -=== "ObserverDecorator" - The ObserverDecorator adds an observable interface to all classes of the class diagram. - - ![Figure 4.15 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.15 The original class diagram
- - ![Figure 4.16 The original class diagram after applying the ObserverDecorator](../myOrganizer/img/MyOrganizerOnlyObservers.svg) -
Figure 4.16 The original class diagram after applying the ObserverDecorator
- -=== "VisitorDecorator" - The VisitorDecorator adds a visitor interface to all classes of the class diagram. - - ![Figure 4.17 The original class diagramm after applying the CopyDecorator](../myOrganizer/img/MyOrganizerNoDecorators.svg) -
Figure 4.17 The original class diagram
- - ![Figure 4.18 The original class diagram after applying the VisitorDecorator](../myOrganizer/img/MyOrganizerOnlyVisitors.svg) -
Figure 4.18 The original class diagram after applying the VisitorDecorator
- - -Because some Decorators are dependent on other Decorators, running prior to them, Decorators all implement the -interface `IDecorator` which has the method `getDependencies()` that returns a list of Decorators that must -be run before the respective Decorator. For example, the VisitorDecorator depends on the GetterDecorator, -so the `getDependencies()` method returns `Collections.singletonList(GetterDecorator.class)`. Therefore, the -CD4Code generator checks the dependencies of the selected Decorators and runs them in the correct order. -If there is a circular dependency, the CD4Code generator throws an error and does not generate any code. - -```java -/** Extend {@link AbstractDecorator} for shared */ -public interface IDecorator extends IVisitor { - - /** - * Add your decorator-visitor to the given traverser - * - * @param traverser the traverser - */ - void addToTraverser(CD4CodeTraverser traverser); - - void init(DecoratorData util, Optional glexOpt); - - /** @return the list of decorators which MUST traverse the AST before */ - @SuppressWarnings("rawtypes") - default Iterable> getMustRunAfter() { - return Collections.singletonList(ICreator.class); - } - -} -``` - - ## Running the CD4Code Generator The execution of the CD4Code Generator follows a structured pipeline. First parsing and validating the model, then managing its symbols, and finally transforming the diagram diff --git a/docs/decorators/AbstractMethodDecorator.md b/docs/decorators/AbstractMethodDecorator.md new file mode 100644 index 000000000..af03a9e8b --- /dev/null +++ b/docs/decorators/AbstractMethodDecorator.md @@ -0,0 +1,36 @@ +# AbstractMethodDecorator + +The `AbstractMethodDecorator` is responsible for adding `abstract` modifiers to all methods defined in the classes +and interfaces of the class diagram, or changing their implementation into abstract methods. This is particularly +useful when generating a base structural framework where the concrete implementation of business logic is expected +to be provided by developers extending these generated base classes. + +## The Core Mechanism + +When the generator runs, this decorator traverses every method (`ASTCDMethod`) in the class diagram and applies a transformation: + +1. **Guard Clauses:** It verifies if the method and its enclosing class/interface should be decorated. +2. **Modifier Update:** It updates the modifiers of the method to include `abstract`. +3. **Body Removal:** It removes any existing method body, as abstract methods cannot have bodies. +4. **Class Modifier Update:** If a class contains abstract methods, the class itself must be declared abstract. The decorator ensures the enclosing class's modifiers are updated accordingly. + +--- + +![Figure 1.1 The original class diagramm after applying the mandatory CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.1 The class diagram after the mandatory CopyDecorator
+ +![Figure 1.2 The original class diagram after applying the AbstractMethodDecorator](../../myOrganizer/img/MyOrganizerOnlyWithAbstractMethodSignatures.svg) +
Figure 1.2 The original class diagram after applying the AbstractMethodDecorator
+ +--- + +## Real-World Breakdown: Generation Strategies + +In the `MyOrganizer` example, if we look at the `Asset` and `Task` classes, they both define a `void process();` +method. After applying the `AbstractMethodDecorator`, these methods are transformed into abstract methods +within the generated Java code, forcing any concrete subclass to provide an implementation. + +```java +// Generated by AbstractMethodDecorator +public abstract void process(); +``` \ No newline at end of file diff --git a/docs/decorators/BuilderDecorator.md b/docs/decorators/BuilderDecorator.md new file mode 100644 index 000000000..6e41158d3 --- /dev/null +++ b/docs/decorators/BuilderDecorator.md @@ -0,0 +1,61 @@ +# BuilderDecorator + +The `BuilderDecorator` implements the Builder Design Pattern by automatically generating a dedicated Builder class for every instantiable class in your class diagram. This is especially useful for classes with numerous attributes, providing a fluent and readable API for object creation instead of relying on massive constructors or numerous setter calls. + +## The Core Mechanism + +When the generator runs, this decorator processes every class (`ASTCDClass`) in the diagram: + +1. **Target Selection:** It identifies classes that require a builder (typically non-abstract classes, or those specifically tagged). +2. **Builder Class Generation:** For a class named `X`, it creates a new class `XBuilder`. +3. **Attribute Duplication:** It duplicates all attributes from the target class into the builder class to hold the intermediate state. +4. **Fluent Setter Generation:** It generates "set" methods (e.g., `setProjectName(String)`) that return `this.realBuilder` for method chaining, ensuring compatibility with inheritance. +5. **Build Method:** It generates a `build()` method that validates the state, constructs, and returns an instance of the target class using the accumulated properties. + +--- + +![Figure 1.1 The original class diagramm after applying the mandatory CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.1 The class diagram after the mandatory CopyDecorator
+ +![Figure 1.2 The original class diagram after applying the BuilderDecorator](../../myOrganizer/img/MyOrganizerOnlyBuilders.svg) +
Figure 1.2 The original class diagram after applying the BuilderDecorator
+ +--- + +## Real-World Breakdown: Generation Strategies + +Looking at the `Project` class, which has multiple attributes (`projectName`, `deadline`, `budget`, `tasks`), creating an instance manually might be cumbersome. The `BuilderDecorator` simplifies this by generating a `ProjectBuilder`. + +```java +// Example of generated fluent setters in ProjectBuilder +public ProjectBuilder setProjectName(String projectName) { + this.projectName = projectName; + return this.realBuilder; +} + +public ProjectBuilder setBudget(double budget) { + this.budget = budget; + return this.realBuilder; +} + +// Example of the final build method +public Project build() { + if(!isValid()){ + throw new IllegalStateException("build called on an incomplete object of type Project."); + } + var v = new Project(); + v.setProjectName(this.projectName); + v.setBudget(this.budget); + // ... set other attributes + return v; +} +``` + +This allows developers to create instances of `Project` with a more concise syntax: + +```java +Project project = new ProjectBuilder() + .setProjectName("New Website") + .setBudget(10000.0) + .build(); +``` \ No newline at end of file diff --git a/docs/decorators/CardinalityDefaultDecorator.md b/docs/decorators/CardinalityDefaultDecorator.md new file mode 100644 index 000000000..13a1ae95d --- /dev/null +++ b/docs/decorators/CardinalityDefaultDecorator.md @@ -0,0 +1,40 @@ +# CardinalityDefaultDecorator + +The `CardinalityDefaultDecorator` initiates Lists, Sets, and Optional attributes of the class diagram with an +empty List, empty Set, or an empty Optional respectively. As the `CopyDecorator` always runs early in the +generation process and adds the attributes defined in the associations and compositions to the respective +classes, the `CardinalityDefaultDecorator` ensures these attributes are safely initialized, preventing +`NullPointerException`s at runtime. + +As raw initialization syntax (like `new ArrayList<>()`) is not natively represented in the class diagram language, +the `CardinalityDefaultDecorator` instead injects this initialization via template hooks directly into the +class's constructors. + +## Core Mechanism +When the generator runs, this decorator traverses every attribute in a class diagram (`ASTCDAttribute`) and applies a targeted transformation: + +1. **Type Routing:** It checks if the attribute is a List, Set, or Optional. Everything else is ignored. +2. **Constructor Generation:** It calls `getOrCreateDecConstructors`. If the decorated class does not already have a constructor, the decorator creates a default, no-argument constructor for it. +3. **Template Injection:** It injects specific Java instantiation code into the body of the constructor. + +--- + +## Real-World Breakdown: Generation Strategies +Looking directly at the generated Java code for the `Project` class, we can see exactly how the `CardinalityDefaultDecorator` handled the different attribute types. + +Standard attributes like `projectName` and `budget` are ignored, but the collections and optionals are handled securely within the generated default constructor: + +```java +public Project() { + /* INJECTED BY CardinalityDefaultDecorator */ + /* generated by template methods.InstantiationEmptyOptional*/ + this.deadline = java.util.Optional.empty(); + + /* INJECTED BY CardinalityDefaultDecorator */ + /* generated by template methods.Instantiation*/ + this.tasks = new java.util.LinkedHashSet(); +} +``` + +Optional attributes like `deadline` are initialized with `java.util.Optional.empty()`, while sets like `tasks` +are initialized with `new java.util.LinkedHashSet()`. Lists are initialized with `new java.util.ArrayList()`. diff --git a/docs/decorators/CopyDecorator.md b/docs/decorators/CopyDecorator.md new file mode 100644 index 000000000..b3e29c9e1 --- /dev/null +++ b/docs/decorators/CopyDecorator.md @@ -0,0 +1,56 @@ +# CopyDecorator + +The `CopyDecorator` is a mandatory, foundational step in the CD4Code generation pipeline. Unlike other decorators +that add optional features, the `CopyDecorator`'s primary role is to create a clean, unified, and complete +Abstract Syntax Tree (AST) from the initial parsed class diagram. It normalizes the diagram's structure, +resolves associations, and sets sensible defaults, preparing the AST for all subsequent decorators. + +## The Core Mechanism + +The `CopyDecorator` is always the first to run. It takes the raw AST from the parser and performs several crucial transformations: + +1. **AST Unification:** It creates a deep copy of the original AST. This ensures that all subsequent modifications by other decorators do not affect the original, parsed model. +2. **Package Creation:** If the class diagram is not explicitly defined within a package, the decorator creates a default package to encapsulate all the elements. +3. **Association Materialization:** It translates abstract `association` and `composition` relationships into concrete class attributes. Based on the defined cardinality, it adds fields to the corresponding classes: + * `[*]` or `[0..*]` becomes a `Set`. + * `[1..*]` becomes a `List`. + * `[1]` or `[1..1]` becomes a direct `Type` reference. + * `[0..1]` becomes an `Optional`. +4. **Default Visibility:** It enforces a "public by default" policy. Any class, attribute, or method without an explicit visibility modifier (`public`, `protected`, `private`) is automatically set to `public`. + +--- + +![Figure 1.1 The original class diagram](../../myOrganizer/img/MyOrganizer.svg) +
Figure 1.1 The original class diagram as defined in the `.cd` file
+ +![Figure 1.2 The class diagram after applying the CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.2 The unified class diagram after the `CopyDecorator` has run
+ +--- + +## Real-World Breakdown: Generation Strategies + +The `CopyDecorator`'s impact is best seen by comparing the user-defined class diagram with the resulting class +diagram after the `CopyDecorator` modiefied it. + +### Association to Attributes + +The original diagram defines a bidirectional association: +`association [*] Task (tasks) <-> (project) Project [1];` + +The `CopyDecorator` dissolves this relationship and injects corresponding attributes into the classes: +* The `Project` class gets a `private Set tasks;` attribute. +* The `Task` class gets a `private Project project;` attribute. + +### Default Visibility + +In the original diagram, the `Task` class and its `taskStatus` attribute have no explicit visibility. + +```cd4code +class Task extends Asset { + Status taskStatus; + void process(); +} +``` + +The `CopyDecorator` automatically promotes them to `public`, making them accessible by default. This unified AST is then passed to other decorators like `GetterDecorator` and `SetterDecorator`, which will later reduce the visibility of the fields to `protected` to enforce encapsulation. \ No newline at end of file diff --git a/docs/decorators/GetterDecorator.md b/docs/decorators/GetterDecorator.md new file mode 100644 index 000000000..a54e83e1c --- /dev/null +++ b/docs/decorators/GetterDecorator.md @@ -0,0 +1,87 @@ +# GetterDecorator + +The `GetterDecorator` is responsible for automatically creating accessor (getter) methods for class attributes. +Rather than generating a basic, one-size-fits-all `get()` method, it intelligently analyzes the multiplicity +(Mandatory, Optional, Set/List) and type (e.g., Booleans vs. Standard Objects) of each attribute to generate +a method for reading attribute values. + +## The Core Mechanism + +When the generator runs, this decorator traverses every attribute in a class diagram (`ASTCDAttribute`) and applies a multi-step transformation: + +1. **Guard Clauses:** It verifies if the attribute should be decorated, ensuring it only processes valid targets. +2. **Multiplicity Routing:** It checks the attribute's definition and routes it to specific generator methods (`decorateMandatory`, `decorateOptional`, `decorateList`, `decorateSet`). +3. **Template Injection:** It creates the method signature and injects templates to fill in the method body. +4. **Encapsulation Enforcement:** At the very end (`updateModifier`), it alters the visibility of the underlying field itself to `protected`. This enforces encapsulation, ensuring that external Java code must route through the newly generated getter methods. + +--- + +![Figure 1.1 The original class diagramm after applying the mandatory CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.1 The class diagram after the mandatory CopyDecorator
+ +![Figure 1.2 The original class diagram after applying the SetterDecorator](../../myOrganizer/img/MyOrganizerOnlyGetter.svg) +
Figure 1.2 The original class diagram after applying the GetterDecorator
+ +--- + +## Real-World Breakdown: Generation Strategies + +Looking at the `Project` class, we can see exactly how the decorator handled Mandatory, Optional, and Collection +data types to create a highly usable Java class. + +### 1. Mandatory Attributes (`[1]`) +For standard attributes like `String projectName` and `double budget`, the decorator generates a standard, direct +accessor. In the resulting class diafram, we see `getProjectName` and `getBudget`. + +```java +// Generated by GetterDecorator -> decorateMandatory +public String getProjectName() { + return this.projectName; +} +``` + +### 2. Optional Attributes (`[0..1]`) +For the `Optional deadline`, simply returning the `Optional` object isn't always good practice. +Instead, the decorator generates two methods (seen in the class diagram as `isPresentDeadline` and `getDeadline`). +The first method `isPresentDeadline()` checks if the value is present, while the second method `getDeadline()` +retrieves the value if it exists, or throws an exception if it doesn't. + +```java +// Generated by GetterDecorator -> decorateOptionalIsPresent +private boolean isPresentDeadline() { + return this.deadline.isPresent(); +} + +// Generated by GetterDecorator -> decorateOptional +private Date getDeadline() { + if (isPresentDeadline()) { + return this.deadline.get(); + } + Log.error("0xA7003x70140 get for Deadline can't return a value. Attribute is empty."); + throw new IllegalStateException(); +} +``` + +### 3. Sets and Lists (`[*]`) +Because `Project` holds multiple `Task`s via an association, the decorator generates the main `getTasks()` method. +However, to follow encapsulation best practices, it also generates a massive suite of delegation functions. + +These methods allow external code to query the collection directly, which results in a much more intuitive code. + +```java +// Generated by GetterDecorator -> decorateSet +public Set getTasks() { + return this.tasks; +} + +// Generated by GetterDecorator -> decorateWithAssocFunctions +// Automatically delegates to the underlying collection +public boolean containsTasks(Object element) { + return this.getTasks().contains(element); +} + +public java.util.stream.Stream streamTasks() { + return this.getTasks().stream(); +} +// ... and many more (iteratorTasks, toArrayTasks, equalsTasks, etc.) +``` \ No newline at end of file diff --git a/docs/decorators/NavigableSetterDecorator.md b/docs/decorators/NavigableSetterDecorator.md new file mode 100644 index 000000000..e708d40a9 --- /dev/null +++ b/docs/decorators/NavigableSetterDecorator.md @@ -0,0 +1,94 @@ +# NavigableSetterDecorator + +The `NaviagableSetterDecorator` depends on the `SetterDecorator` and shares the same enabler and disabler as +the `SetterDecorator` by default. This means that the `NaviagableSetterDecorator` is precisely then applied, +when the `SetterDecorator` is applied is always applied. Furthermore, as the `NaviagableSetterDecorator` +depends on the SetterDecorator, it is applied after the SetterDecorator. + +The `NavigableSetterDecorator` is responsible for automatically managing **bidirectional associations** (`<->`). +When an association is navigable from both sides, this decorator injects the boilerplate code necessary to keep +both ends of the relationship perfectly in sync, preventing dangling references and infinite recursion. + +## The Core Mechanism + +To safely link two objects without causing an infinite loop (where Object A updates Object B, which triggers Object B to update Object A, and so on), the decorator employs a two-part strategy: + +1. **The "Local" Setter:** It generates a new, hidden method (e.g., `set*Local`) that silently updates the underlying field *without* notifying the other side. +2. **The Hook Injection:** It injects a template hook into the standard, public setter. This hook automatically calls the other object's "Local" method. + +--- + +![Figure 1.1 The original class diagramm after applying the mandatory CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.1 The class diagram after the mandatory CopyDecorator
+ +![Figure 1.2 The original class diagram after applying the SetterDecorator and NavigableSetterDecorator](../../myOrganizer/img/MyOrganizerOnlyNavigableSetter.svg) +
Figure 1.2 The original class diagram after applying the SetterDecorator and the NavigableSetterDecorator
+ +--- + +## Real-World Breakdown: Generation Strategies + +To see this in action, we look at the bidirectional association between `Task` and `Project` in our class diagram: +`association [*] Task (tasks) <-> (project) Project [1];` + +Because both sides are navigable, the `NavigableSetterDecorator` modifies the generated Java code for both classes +to ensure they stay perfectly synchronized. + +### 1. Generating the "Local" Setter +To prevent infinite recursion during updates, the decorator generates safe, localized mutators for both the `[1]` +side (Task) and the `[*]` side (Project). These methods handle the internal assignment but purposefully do not +attempt to update the other side. + +```java +// Inside Task class: Generated by NavigableSetterDecorator +public void setProjectLocal(MyOrganizer.Project project) { + /* Hookpoint: Setter:Before */ + this.project = project; + /* Hookpoint: Setter:After */ +} + +// Inside Project class: Generated by NavigableSetterDecorator +public boolean addTasksLocal(MyOrganizer.Task tasks) { + /* Hookpoint: Setter:Before */ + var __ret = this.tasks.add(tasks); + /* Hookpoint: Setter:After */ + return __ret; +} +``` + +### 2. Hook Injection +Once the local setters exist, the decorator takes advantage of the empty `Setter:After` hook points left behind +by the standard `SetterDecorator`. It injects a call to the opposite class's `*Local` method. + +If a developer calls `setProject` on a Task, the injected hook immediately ensures the `Project` adds that `Task` +to its internal set. + +```java +// Inside Task class: Modified standard setter +public void setProject(MyOrganizer.Project project) { + /* Hookpoint: Setter:Before */ + this.project = project; + /* Hookpoint: Setter:After */ + + /* INJECTED BY NavigableSetterDecorator */ + this.project.addTasksLocal((Task)this); +} +``` + +Conversely, if a developer calls `addTasks` on a `Project`, the injected hook assigns that `Project` to the +`Task`'s internal set. + +```java +// Inside Project class: Modified standard setter +public boolean addTasks(MyOrganizer.Task tasks) { + /* Hookpoint: Setter:Before */ + var __ret = this.tasks.add(tasks); + /* Hookpoint: Setter:After */ + + /* INJECTED BY NavigableSetterDecorator */ + tasks.setProjectLocal((Project)this); + return __ret; +} +``` + +This ensures that both sides of the relationship are perfectly in sync without manual state management. \ No newline at end of file diff --git a/docs/decorators/ObserverDecorator.md b/docs/decorators/ObserverDecorator.md new file mode 100644 index 000000000..1d9aac340 --- /dev/null +++ b/docs/decorators/ObserverDecorator.md @@ -0,0 +1,44 @@ +# ObserverDecorator + +The `ObserverDecorator` implements the Observer Design Pattern by automatically turning the classes in your class +diagram into observable entities. It generates the necessary infrastructure allowing other components of your +system to subscribe to and react to state changes within these generated objects. + +## The Core Mechanism + +When the generator runs, this decorator traverses the AST and enriches it with the Observer pattern: + +1. **Listener Interface Generation:** For a class `X`, it creates a listener/observer interface (e.g., `XListener` or `XObserver`). +2. **Subscription Management:** It adds fields to the target class to manage a collection of registered listeners. +3. **Registration Methods:** It generates methods in the target class to `addObserver()` and `removeObserver()`. +4. **Notification Hooks:** It injects code into state-changing methods (like setters, generated by the `SetterDecorator`) to notify all registered observers whenever a value is updated. + +--- + +![Figure 1.1 The original class diagramm after applying the mandatory CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.1 The class diagram after the mandatory CopyDecorator
+ +![Figure 1.2 The original class diagram after applying the ObserverDecorator](../../myOrganizer/img/MyOrganizerOnlyObservers.svg) +
Figure 1.2 The original class diagram after applying the ObserverDecorator
+ +--- + +## Real-World Breakdown: Generation Strategies + +If we look at the `Task` class, we might want UI components or project managers to be notified when the +`taskStatus` changes. By enabling the `ObserverDecorator`, the class becomes observable. + + +// TODO THIS IS ALL MISSING +The decorator will typically generate an interface: +```java + +``` + +And add management methods to the `Task` class: +```java + +``` + +State changes (e.g., via generated setters) will then automatically trigger these notifications, +ensuring the rest of the application remains in sync with the model's data. \ No newline at end of file diff --git a/docs/decorators/SetterDecorator.md b/docs/decorators/SetterDecorator.md new file mode 100644 index 000000000..9882bbfbb --- /dev/null +++ b/docs/decorators/SetterDecorator.md @@ -0,0 +1,98 @@ +# SetterDecorator + +The `SetterDecorator` is responsible for automatically creating setter methods for class attributes. +Rather than generating a basic, one-size-fits-all `set()` method, it intelligently +analyzes the **multiplicity** (Mandatory, Optional, Set/List) and **properties** (Ordered vs. Unordered) of each +attribute to generate a method for modifying attribute values. + +## The Core Mechanism + +When the generator runs, this decorator traverses every attribute in a class diagram (`ASTCDAttribute`) and applies a multi-step transformation: + +1. **Guard Clauses:** It immediately skips any attributes marked as `derived`, `readonly`, or `final`, because these logically should not have public mutators. +2. **Multiplicity Routing:** It checks the attribute's definition and routes it to specific generator methods (`decorateMandatory`, `decorateOptionalAbsent`, `decorateAddUnordered`, etc.). +3. **Template Injection:** It creates the method signature and injects templates to fill in the method body. +4. **Encapsulation Enforcement:** At the very end (`updateModifier`), it alters the visibility of the underlying field itself to `protected`. This enforces encapsulation, ensuring that external Java code must route through the newly generated setter methods. + +--- + +![Figure 1.1 The original class diagramm after applying the mandatory CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.1 The class diagram after the mandatory CopyDecorator
+ +![Figure 1.2 The original class diagram after applying the SetterDecorator](../../myOrganizer/img/MyOrganizerOnlySetter.svg) +
Figure 1.2 The original class diagram after applying the SetterDecorator
+ +--- + +## Real-World Breakdown: Generation Strategies +The generated setters are highly customizable through hook points. Additional to the basic assignment logic, +the decorator also leaves empty template hook points (`Setter:Before` and `Setter:After`) that you can use to +inject custom logic. This is used in the `NavigableSetterDecorator` to automatically manage bidirectional +associations, but you can also use it for your own custom logic. + +Depending on how an attribute is defined in your class diagram, the `SetterDecorator` will produce radically different +Java code. The `Project` class is a perfect example, as it contains all three primary multiplicity types: Mandatory, +Optional, and Set. + +Here is how the decorator handles each scenario: +### 1. Mandatory Attributes (`[1]`) +For standard, required attributes like `String projectName` and `double budget`, the decorator generates a straightforward mutator. +* +```java +// Generated by SetterDecorator -> decorateMandatory +public void setProjectName(String projectName) { + /* Hookpoint: Setter:Before */ + this.projectName = projectName; + /* Hookpoint: Setter:After */ +} + +public void setBudget(double budget) { + /* Hookpoint: Setter:Before */ + this.budget = budget; + /* Hookpoint: Setter:After */ +} +``` + +### 2. Optional Attributes (`[0..1]`) +Because deadline is explicitly modeled as an `Optional`, the CD4Code generator needs to provide a safe way to +update or clear this value. For this the decorator generates two distinct methods. +The first one is `setDeadline(Date deadline)` that updates the value if it is not null. +The second one is `setDeadlineAbsent()` that clears the value. + +```java +// Generated by SetterDecorator -> decorateOptSet +private void setDeadline(Date deadline) { + /* Hookpoint: Setter:Before */ + this.deadline = Optional.ofNullable(deadline); + /* Hookpoint: Setter:After */ +} + +// Generated by SetterDecorator -> decorateOptionalAbsent +private void setDeadlineAbsent() { + /* Hookpoint: Setter:Before */ + this.deadline = Optional.empty(); + /* Hookpoint: Setter:After */ +} +``` + +### 3. Sets and Lists (`[*]`) +The bidirectional association creates a `Set tasks` in the Project class. Instead of overwriting the whole +set with a basic `setTasks()`, the decorator generates muliple collection management methods (addTasks and removeTasks). + +```java +// Generated by SetterDecorator -> decorateAddUnordered +public boolean addTasks(MyOrganizer.Task tasks) { + /* Hookpoint: Setter:Before */ + var __ret = this.tasks.add(tasks); + /* Hookpoint: Setter:After */ + return __ret; +} + +// Generated by SetterDecorator -> decorateRemoveUnordered +public boolean removeTasks (MyOrganizer.Task tasks) { + /* Hookpoint: Setter:Before */ + var __ret = this.tasks.remove(tasks); + /* Hookpoint: Setter:After */ + return __ret; +} +``` \ No newline at end of file diff --git a/docs/decorators/VisitorDecorator.md b/docs/decorators/VisitorDecorator.md new file mode 100644 index 000000000..3b022daab --- /dev/null +++ b/docs/decorators/VisitorDecorator.md @@ -0,0 +1,76 @@ +# VisitorDecorator + +The `VisitorDecorator` implements the Visitor Design Pattern by generating the necessary infrastructure to +traverse and process the object graph formed by the generated classes. This pattern is essential for separating +algorithms from the object structure on which they operate, making it easy to add new operations without +modifying the generated classes themselves. + +## The Core Mechanism + +The `VisitorDecorator` operates globally across the class diagram to set up the visitor pattern: + +1. **Visitor Interface Generation:** It generates a single, central visitor interface for the entire class diagram. For a diagram named `MyOrganizer`, this interface will be named `IMyOrganizerVisitor`. +2. **`visit` Methods:** For every class `X` in the diagram, it adds a corresponding abstract `visit(X node)` method to the `IMyOrganizerVisitor` interface. This ensures that a concrete visitor implementation must provide logic for handling each specific type. +3. **`accept` Method Injection:** It injects a public `accept(IMyOrganizerVisitor visitor)` method into every generated class (`Task`, `Project`, etc.). +4. **Delegation:** The implementation of the generated `accept` method is a single call that delegates control to the visitor, e.g., `visitor.visit((Task) this)`. This is the core of the "double dispatch" mechanism in the Visitor pattern. + +--- + +![Figure 1.1 The original class diagramm after applying the mandatory CopyDecorator](../../myOrganizer/img/MyOrganizerNoDecorators.svg) +
Figure 1.1 The class diagram after the mandatory CopyDecorator
+ +![Figure 1.2 The original class diagram after applying the VisitorDecorator](../../myOrganizer/img/MyOrganizerOnlyVisitors.svg) +
Figure 1.2 The original class diagram after applying the VisitorDecorator
+ +--- + +## Real-World Breakdown: Generation Strategies + +In the `MyOrganizer` example, you have a `Project` that contains `Task`s. If you want to write a custom tool to perform an operation on this structure (e.g., validate all tasks), you can use the generated visitor infrastructure. + +### Generated `IMyOrganizerVisitor` Interface +The decorator first creates the central interface with a `visit` method for each class: + +```java +// Generated IMyOrganizerVisitor.java +package MyOrganizer; + +public interface IMyOrganizerVisitor { + void visit(Asset node); + void visit(Task node); + void visit(Project node); + void visit(Day node); + // ... and so on for all other types +} +``` + +### Generated `accept` Method +The decorator injects a `accept` method into every generated class For the `Task` class, it would look like this: + +```java +// Injected into Task.java +public void accept(MyOrganizer.IMyOrganizerVisitor visitor) { + visitor.visit((Task) this); +} +``` + +## Usage +A developer can now implement the IMyOrganizerVisitor interface (or extend the generated default traversal class +`MyOrganizerVisitorImplementation`) to create a visitor. This visitor can then be used to traverse the object +graph and perform operations on each node. This separates the logic of the operation from the data structure of +the generated classes, allowing for clean and maintainable code. + +```java +// A custom implementation to validate tasks +public class TaskValidator implements IMyOrganizerVisitor { + @Override + public void visit(Task task) { + // Add validation logic for Task objects here + if (task.getTaskStatus() == Status.OPEN) { + System.out.println("Task is still open!"); + } + } + + // Abstract methods for other nodes would need to be implemented or ignored if utilizing the interface directly +} +``` \ No newline at end of file diff --git a/docs/myOrganizer/cds/MyOrganizer.cd b/docs/myOrganizer/cds/MyOrganizer.cd index d5d9dcad4..c25aa5d61 100644 --- a/docs/myOrganizer/cds/MyOrganizer.cd +++ b/docs/myOrganizer/cds/MyOrganizer.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; classdiagram MyOrganizer { @@ -10,14 +11,14 @@ classdiagram MyOrganizer { } class Task extends Asset { - private String taskName; - protected Status taskStatus; + Status taskStatus; void process(); } class Project extends Asset { public String projectName; - double budget; + private Optional deadline; + protected double budget; void process(); } @@ -25,6 +26,6 @@ classdiagram MyOrganizer { Date date; } - association [1] Day (day) -> (tasks) Task [1]; + association [1] Day (day) -> (tasks) Task [*]; association [*] Task (tasks) <-> (project) Project [1]; } \ No newline at end of file diff --git a/docs/myOrganizer/cds/MyOrganizerNoDecorators.cd b/docs/myOrganizer/cds/MyOrganizerNoDecorators.cd index f0e577bf8..b4962613b 100644 --- a/docs/myOrganizer/cds/MyOrganizerNoDecorators.cd +++ b/docs/myOrganizer/cds/MyOrganizerNoDecorators.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -12,25 +13,25 @@ public classdiagram MyOrganizer { } public class Task extends Asset { - private String taskName; - protected Status taskStatus; + public Status taskStatus; public void process(); public MyOrganizer.Project project; } public class Project extends Asset { public String projectName; - public double budget; + private Optionaldeadline; + protected double budget; public void process(); public Settasks; } public class Day { public Date date; - public MyOrganizer.Task tasks; + public Settasks; } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; } diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd b/docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd index bffff32ca..eba5d4c79 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlyBuilders.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -12,25 +13,25 @@ public classdiagram MyOrganizer { } public class Task extends Asset { - private String taskName; - protected Status taskStatus; + public Status taskStatus; public void process(); public MyOrganizer.Project project; } public class Project extends Asset { public String projectName; - public double budget; + private Optionaldeadline; + protected double budget; public void process(); public Settasks; } public class Day { public Date date; - public MyOrganizer.Task tasks; + public Settasks; } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; public abstract class AssetBuilder { protected AssetBuilder realBuilder; @@ -46,10 +47,8 @@ public classdiagram MyOrganizer { private boolean isValid(); public Task build(); public Task unsafeBuild(); - protected String taskName; protected Status taskStatus; protected MyOrganizer.Project project; - public TaskBuilder setTaskName(String taskName); public TaskBuilder setTaskStatus(Status taskStatus); public TaskBuilder setProject(MyOrganizer.Project project); @@ -61,11 +60,14 @@ public classdiagram MyOrganizer { public Project build(); public Project unsafeBuild(); protected String projectName; + protected Optionaldeadline; protected double budget; protected Settasks; public ProjectBuilder setProjectName(String projectName); + public ProjectBuilder setDeadline(Date deadline); public ProjectBuilder setBudget(double budget); public ProjectBuilder setTasks(Settasks); + public ProjectBuilder setDeadlineAbsent(); public ProjectBuilder setTasksAbsent(); } @@ -76,9 +78,10 @@ public classdiagram MyOrganizer { public Day build(); public Day unsafeBuild(); protected Date date; - protected MyOrganizer.Task tasks; + protected Settasks; public DayBuilder setDate(Date date); - public DayBuilder setTasks(MyOrganizer.Task tasks); + public DayBuilder setTasks(Settasks); + public DayBuilder setTasksAbsent(); } diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd b/docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd index 4823ccc52..bbc074111 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlyDefaultsForCardinalityAttrs.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -12,15 +13,15 @@ public classdiagram MyOrganizer { } public class Task extends Asset { - private String taskName; - protected Status taskStatus; + public Status taskStatus; public void process(); public MyOrganizer.Project project; } public class Project extends Asset { public String projectName; - public double budget; + private Optionaldeadline; + protected double budget; public void process(); public Settasks; public Project(); @@ -28,10 +29,11 @@ public classdiagram MyOrganizer { } public class Day { public Date date; - public MyOrganizer.Task tasks; + public Settasks; + public Day(); } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; } diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd b/docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd index aafe51fc3..2d8d01f06 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlyGetter.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -12,22 +13,23 @@ public classdiagram MyOrganizer { } public class Task extends Asset { - protected String taskName; protected Status taskStatus; public void process(); protected MyOrganizer.Project project; - private String getTaskName(); - protected Status getTaskStatus(); + public Status getTaskStatus(); public MyOrganizer.Project getProject(); } public class Project extends Asset { protected String projectName; + protected Optionaldeadline; protected double budget; public void process(); protected Settasks; public String getProjectName(); - public double getBudget(); + private Date getDeadline(); + private boolean isPresentDeadline(); + protected double getBudget(); public SetgetTasks(); public boolean containsTasks(Object element); public boolean containsAllTasks(java.util.Collectioncollection); @@ -45,12 +47,24 @@ public classdiagram MyOrganizer { } public class Day { protected Date date; - protected MyOrganizer.Task tasks; + protected Settasks; public Date getDate(); - public MyOrganizer.Task getTasks(); + public SetgetTasks(); + public boolean containsTasks(Object element); + public boolean containsAllTasks(java.util.Collectioncollection); + public boolean isEmptyTasks(); + public java.util.IteratoriteratorTasks(); + public int sizeTasks(); + public MyOrganizer.Task []toArrayTasks(MyOrganizer.Task []array); + public Object []toArrayTasks(); + public java.util.SpliteratorspliteratorTasks(); + public java.util.stream.StreamstreamTasks(); + public java.util.stream.StreamparallelStreamTasks(); + public boolean equalsTasks(Object o); + public int hashCodeTasks(); } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; } diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd b/docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd index 99ed5b2f4..6f161db39 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlyNavigableSetter.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -12,23 +13,24 @@ public classdiagram MyOrganizer { } public class Task extends Asset { - protected String taskName; protected Status taskStatus; public void process(); protected MyOrganizer.Project project; - private void setTaskName(String taskName); - protected void setTaskStatus(Status taskStatus); + public void setTaskStatus(Status taskStatus); public void setProject(MyOrganizer.Project project); public void setProjectLocal(MyOrganizer.Project project); } public class Project extends Asset { protected String projectName; + protected Optionaldeadline; protected double budget; public void process(); protected Settasks; public void setProjectName(String projectName); - public void setBudget(double budget); + private void setDeadlineAbsent(); + private void setDeadline(Date deadline); + protected void setBudget(double budget); public boolean addTasks(MyOrganizer.Task tasks); public boolean removeTasks(MyOrganizer.Task tasks); public boolean addTasksLocal(MyOrganizer.Task tasks); @@ -37,12 +39,13 @@ public classdiagram MyOrganizer { } public class Day { protected Date date; - protected MyOrganizer.Task tasks; + protected Settasks; public void setDate(Date date); - public void setTasks(MyOrganizer.Task tasks); + public boolean addTasks(MyOrganizer.Task tasks); + public boolean removeTasks(MyOrganizer.Task tasks); } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; } diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd b/docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd index ea665cc02..dc340f718 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlyObservers.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -16,22 +17,21 @@ public classdiagram MyOrganizer { } public class Task extends Asset implements de.monticore.cd.ICDObservable{ - private String taskName; - protected Status taskStatus; + public Status taskStatus; public void process(); public MyOrganizer.Project project; protected ListobserverList; public void addObserver(MyOrganizer.ITaskObserver observer); public void removeObserver(MyOrganizer.ITaskObserver observer); protected void notifyObservers(); - protected void notifyObserversSetTaskName(String ov); protected void notifyObserversSetTaskStatus(Status ov); protected void notifyObserversSetProject(MyOrganizer.Project ov); } public class Project extends Asset implements de.monticore.cd.ICDObservable{ public String projectName; - public double budget; + private Optionaldeadline; + protected double budget; public void process(); public Settasks; protected ListobserverList; @@ -39,6 +39,7 @@ public classdiagram MyOrganizer { public void removeObserver(MyOrganizer.IProjectObserver observer); protected void notifyObservers(); protected void notifyObserversSetProjectName(String ov); + protected void notifyObserversSetDeadline(Optionalov); protected void notifyObserversSetBudget(double ov); protected void notifyObserversAddTasks(MyOrganizer.Task newElem); protected void notifyObserversRemoveTasks(MyOrganizer.Task elem); @@ -46,16 +47,17 @@ public classdiagram MyOrganizer { } public class Day implements de.monticore.cd.ICDObservable{ public Date date; - public MyOrganizer.Task tasks; + public Settasks; protected ListobserverList; public void addObserver(MyOrganizer.IDayObserver observer); public void removeObserver(MyOrganizer.IDayObserver observer); protected void notifyObservers(); protected void notifyObserversSetDate(Date ov); - protected void notifyObserversSetTasks(MyOrganizer.Task ov); + protected void notifyObserversAddTasks(MyOrganizer.Task newElem); + protected void notifyObserversRemoveTasks(MyOrganizer.Task elem); } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; public interface IAssetObserver extends de.monticore.cd.ICDObserver{ public void notifyUpdate(Asset clazz); @@ -63,7 +65,6 @@ public classdiagram MyOrganizer { } public interface ITaskObserver extends de.monticore.cd.ICDObserver{ public void notifyUpdate(Task clazz); - public void notifyUpdateSetTaskName(Task clazz,String ov); public void notifyUpdateSetTaskStatus(Task clazz,Status ov); public void notifyUpdateSetProject(Task clazz,MyOrganizer.Project ov); @@ -71,6 +72,7 @@ public classdiagram MyOrganizer { public interface IProjectObserver extends de.monticore.cd.ICDObserver{ public void notifyUpdate(Project clazz); public void notifyUpdateSetProjectName(Project clazz,String ov); + public void notifyUpdateSetDeadline(Project clazz,Optionalov); public void notifyUpdateSetBudget(Project clazz,double ov); public void notifyUpdateAddTasks(Project clazz,MyOrganizer.Task newElem); public void notifyUpdateRemoveTasks(Project clazz,MyOrganizer.Task elem); @@ -79,7 +81,8 @@ public classdiagram MyOrganizer { public interface IDayObserver extends de.monticore.cd.ICDObserver{ public void notifyUpdate(Day clazz); public void notifyUpdateSetDate(Day clazz,Date ov); - public void notifyUpdateSetTasks(Day clazz,MyOrganizer.Task ov); + public void notifyUpdateAddTasks(Day clazz,MyOrganizer.Task newElem); + public void notifyUpdateRemoveTasks(Day clazz,MyOrganizer.Task elem); } diff --git a/docs/myOrganizer/cds/MyOrganizerOnlySetter.cd b/docs/myOrganizer/cds/MyOrganizerOnlySetter.cd index 0c16b757a..53d88494e 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlySetter.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlySetter.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -12,34 +13,36 @@ public classdiagram MyOrganizer { } public class Task extends Asset { - protected String taskName; protected Status taskStatus; public void process(); protected MyOrganizer.Project project; - private void setTaskName(String taskName); - protected void setTaskStatus(Status taskStatus); + public void setTaskStatus(Status taskStatus); public void setProject(MyOrganizer.Project project); } public class Project extends Asset { protected String projectName; + protected Optionaldeadline; protected double budget; public void process(); protected Settasks; public void setProjectName(String projectName); - public void setBudget(double budget); + private void setDeadlineAbsent(); + private void setDeadline(Date deadline); + protected void setBudget(double budget); public boolean addTasks(MyOrganizer.Task tasks); public boolean removeTasks(MyOrganizer.Task tasks); } public class Day { protected Date date; - protected MyOrganizer.Task tasks; + protected Settasks; public void setDate(Date date); - public void setTasks(MyOrganizer.Task tasks); + public boolean addTasks(MyOrganizer.Task tasks); + public boolean removeTasks(MyOrganizer.Task tasks); } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; } diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd b/docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd index 37f8f3490..bfa748ab7 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlyVisitors.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -13,23 +14,24 @@ public classdiagram MyOrganizer { } public class Task extends Asset { - protected String taskName; protected Status taskStatus; public void process(); protected MyOrganizer.Project project; - private String getTaskName(); - protected Status getTaskStatus(); + public Status getTaskStatus(); public MyOrganizer.Project getProject(); public void accept(MyOrganizer.IMyOrganizerVisitor visitor); } public class Project extends Asset { protected String projectName; + protected Optionaldeadline; protected double budget; public void process(); protected Settasks; public String getProjectName(); - public double getBudget(); + private Date getDeadline(); + private boolean isPresentDeadline(); + protected double getBudget(); public SetgetTasks(); public boolean containsTasks(Object element); public boolean containsAllTasks(java.util.Collectioncollection); @@ -48,13 +50,25 @@ public classdiagram MyOrganizer { } public class Day { protected Date date; - protected MyOrganizer.Task tasks; + protected Settasks; public Date getDate(); - public MyOrganizer.Task getTasks(); + public SetgetTasks(); + public boolean containsTasks(Object element); + public boolean containsAllTasks(java.util.Collectioncollection); + public boolean isEmptyTasks(); + public java.util.IteratoriteratorTasks(); + public int sizeTasks(); + public MyOrganizer.Task []toArrayTasks(MyOrganizer.Task []array); + public Object []toArrayTasks(); + public java.util.SpliteratorspliteratorTasks(); + public java.util.stream.StreamstreamTasks(); + public java.util.stream.StreamparallelStreamTasks(); + public boolean equalsTasks(Object o); + public int hashCodeTasks(); public void accept(MyOrganizer.IMyOrganizerVisitor visitor); } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; public interface IMyOrganizerVisitor { public abstract void visit(Asset node); diff --git a/docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd b/docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd index be6ffbb26..d67992861 100644 --- a/docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd +++ b/docs/myOrganizer/cds/MyOrganizerOnlyWithAbstractMethodSignatures.cd @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ import java.util.Date; +import java.util.Optional; import java.util.*; public classdiagram MyOrganizer { package MyOrganizer { @@ -12,25 +13,25 @@ public classdiagram MyOrganizer { } public abstract class Task extends Asset { - private String taskName; - protected Status taskStatus; + public Status taskStatus; public abstract void process(); public MyOrganizer.Project project; } public abstract class Project extends Asset { public String projectName; - public double budget; + private Optionaldeadline; + protected double budget; public abstract void process(); public Settasks; } public class Day { public Date date; - public MyOrganizer.Task tasks; + public Settasks; } - public association public [1]Day(day)->(tasks)Task [1]public; + public association public [1]Day(day)->(tasks)Task[*]public; public association public[*]Task(tasks)<->(project)Project [1]public; } diff --git a/docs/myOrganizer/img/MyOrganizer.svg b/docs/myOrganizer/img/MyOrganizer.svg index 46b7df356..fb8526dcc 100644 --- a/docs/myOrganizer/img/MyOrganizer.svg +++ b/docs/myOrganizer/img/MyOrganizer.svg @@ -1,186 +1,186 @@ - + - - + + - + - - + + - - + + - - + + - + - day - 1 + day + 1 - + - + - day + day - + - tasks - 1 + tasks + * - + - + - tasks + tasks - - + + - + - tasks - * + tasks + * - + - + - tasks + tasks - + - project - 1 + project + 1 - + - + - project + project - - - - Β«enumΒ» - Status - - - PROCESSING - DONE - OPEN - - + + + + Β«enumΒ» + Status + + + PROCESSING + DONE + OPEN + + - + - - - - Β«abstractΒ» - Asset - + + + + Β«abstractΒ» + Asset + - + - void process(); + void process(); - - - - - Task - - - - String taskName; - - # Status taskStatus; + + + + + Task + + + Status taskStatus; - + - void process(); + void process(); - - - - - Project - - - + String projectName; + + + + + Project + + + + String projectName; + + - Optional<Date>deadline; - double budget; + # double budget; - + - void process(); + void process(); - - - - - Day - - - Date date; + + + + + Day + + + Date date; - + - - CD + + CD