Skip to content

Commit

Permalink
doc: add java doc for Model class
Browse files Browse the repository at this point in the history
  • Loading branch information
bamthomas committed Oct 29, 2024
1 parent 8bfd97f commit 35324ea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/org/icij/ftm/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

import static java.lang.String.format;

/**
* Java encapsulation of Map of Map YAML models. It makes easier to manipulate models and centralize code generation rules.
* <p>
* parents instance is the same reference for all Model objects event if it is not static because harder to test and initialize.
* </p>
* <p>
* yaml object is the original yaml Map<String, Object> read from FtM models. We use this object for equal/hash methods.
* </p>
* <p>
* mixins instance is here to "help" the mapping of Java classes with multiple inheritance FtM models.
* </p>
*/
public class Model {
private final static Logger logger = LoggerFactory.getLogger(Model.class);
final Map<String, Model> parents;
Expand All @@ -38,6 +50,10 @@ public String name() {
return yaml.keySet().iterator().next();
}

/**
* Recursive method to find a concrete parent (java class) for the current model.
* @return the parent string model name with isConcrete = true from the inheritance tree.
*/
public Optional<String> concreteParent() {
List<String> extendz = getExtends();
List<String> concreteParents = extendz.stream().filter(p -> parents.get(p) == null || parents.get(p).isConcrete()).collect(Collectors.toList());
Expand Down

0 comments on commit 35324ea

Please sign in to comment.