Skip to content

Commit

Permalink
reindented
Browse files Browse the repository at this point in the history
  • Loading branch information
kolmar committed Aug 29, 2023
1 parent 2b8b28c commit d553ac9
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ package org.mps_cli.model

class SRepository {

SRepository(List<SModuleBase> modules, List<SLanguage> languages) {
this.modules = modules.asImmutable()
this.languages = languages.asImmutable()

this.models = modules.collectMany { it.models }.asImmutable()
this.nodes = models.collectMany { it.allNodes }.asImmutable()
this.id2modelsCache = models.collectEntries {[it.modelId, it] }.asImmutable()
this.id2ModulesCache = modules.collectEntries {[it.moduleId, it] }.asImmutable()
}

private List<SModuleBase> modules;
private List<SLanguage> languages;

Expand All @@ -20,13 +10,26 @@ class SRepository {
private Map<String, SModel> id2modelsCache;
private Map<String, SModuleBase> id2ModulesCache;

SRepository(List<SModuleBase> modules, List<SLanguage> languages) {
this.modules = modules.asImmutable()
this.languages = languages.asImmutable()

this.models = modules.collectMany { it.models }.asImmutable()
this.nodes = models.collectMany { it.allNodes }.asImmutable()
this.id2modelsCache = models.collectEntries { [it.modelId, it] }.asImmutable()
this.id2ModulesCache = modules.collectEntries { [it.moduleId, it] }.asImmutable()
}

List<SModuleBase> getModules() { modules }

List<SLanguage> getLanguages() { languages }

List<SModel> allModels() { models }

List<SNode> allNodes() { nodes }

Map<String, SModel> id2models() { id2modelsCache }

Map<String, SModuleBase> id2modules() { id2ModulesCache }

List<SModel> findModelByName(String modelName) {
Expand All @@ -44,7 +47,7 @@ class SRepository {
}

List<SNode> nodesOfConcept(String fullyQualifiedConceptName) {
allNodes().findAll { it.concept.name == fullyQualifiedConceptName}
allNodes().findAll { it.concept.name == fullyQualifiedConceptName }
}

List<SNode> nodesOfShortConceptName(String shortConceptName) {
Expand All @@ -61,15 +64,15 @@ class SRepository {
}

Set<SConcept> conceptsOfLanguage(String langName) {
languages.find {it.name == langName}?.concepts
languages.find { it.name == langName }?.concepts
}

SConcept findConceptByShortName(String conceptShortName) {
def ending = "." + conceptShortName
languages.collectMany {it.concepts }.find { it.name.endsWith(ending) }
languages.collectMany { it.concepts }.find { it.name.endsWith(ending) }
}

SModuleBase findModuleByName(String moduleName) {
modules.find {it.name.equals(moduleName) }
modules.find { it.name.equals(moduleName) }
}
}

0 comments on commit d553ac9

Please sign in to comment.