Central model instance via singleton

This commit is contained in:
joss 2025-04-25 18:51:25 +02:00
parent ca92fd78c8
commit 1a9aa98c72
2 changed files with 19 additions and 10 deletions

View file

@ -18,10 +18,22 @@ import java.util.HashMap;
* was die deutlich häufiger ausgeführte Operation sein sollte.
*/
public class Model {
// die Hilfsvariable für das Singleton-Pattern
private static Model model = null;
private HashMap<String, DataObject> objs;
private HashMap<String, String> relations;
/**
* Singleton.
*/
public static Model getModel() {
if (model == null)
model = new Model();
return model;
}
/**
* Initialisiert ein leeres Model.
*/
@ -56,8 +68,9 @@ public class Model {
g1.addMember("students/jotto5");
g2.addMember("students/vnachn");
g2.addMember("students/ltorva");
g3.addMember("alovel");
g3.addMember("aturin");
g3.addMember("students/alovel");
g3.addMember("students/aturin");
g3.addMember("students/ltorva");
}
/*