From b32be67ba8968d7e59a443142a59dc33db12b3d4 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Thu, 5 Nov 2020 14:24:30 +0100 Subject: [PATCH] docs: Improve GenModel explanation in README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 23ad28f2..7bdb4539 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,24 @@ public class GenModel implements ClassModelDecorator ``` -Check out [Class Model Definition](doc/ClassModelDefinition.md) in the docs for more details and options. +Within `GenModel`, we define our data model using a familiar yet shortened Java syntax. +Every nested class is translated to a top-level class in the `src/main/java` source directory. +[Class Model Definition](doc/ClassModelDefinition.md) in the docs describes this with more details and options. +For now, we present a simple example in which we define three classes each with some attributes and associations. + +Attributes are defined just like a normal field. +Fulib takes care of generating getters and setters. +It also ensures the correct access modifiers (`private`, `public`) are used in the generated code. +We can simply omit them when defining the model within `GenModel`. + +Associations are defined using the `@Link` annotation. +You specify the name of the reverse role as the annotation argument. +This way, fulib can generate setters that ensure referential integrity. +To-many associations are specified by wrapping the target type in a collection, e.g. `List`. +Instead of a setter, fulib will generate `with` and `without` methods for these associations. + +For brevity, we do not show the generated code here. +However, you can [browse the generated files](test/src/main/java/de/uniks/studyright). ### Generating Java Code