@Test void testClassConfigLoading() { Set<ClassDefinition> classDefinitions = classDefinitionDao.parseClassFiles(null); Assertions.assertSame(classDefinitions.size(), 1); ClassDefinition c = classDefinitions.iterator().next(); Assertions.assertEquals(c.getName(), "ClassExample1"); Assertions.assertEquals(c.getDescription().get(0), "Description"); Assertions.assertEquals(c.getWelcomeMessage(), "WelcomeMessage"); Assertions.assertEquals(c.getPreferedColor(), "PreferredTextColor"); Assertions.assertEquals(c.getItemType(), "ItemType"); Assertions.assertEquals(c.getClassType(), "Primary"); Assertions.assertEquals(c.getItemType(), "ItemType"); Assertions.assertEquals(c.getSkillpointsPerLevel(), 10); Assertions.assertEquals(c.getAttributepointsPerLevel(), 11); }
public Set<ClassDefinition> parseClassFiles(Path path) { Set<ClassDefinition> set = new HashSet<>(); try { Map<String, Path> stringPathMap = preloadClassDefs(path, set); for (Map.Entry<String, Path> stringPathEntry : stringPathMap.entrySet()) { String key = stringPathEntry.getKey(); Path p = stringPathEntry.getValue(); try (FileConfig of = FileConfig.of(p)) { of.load(); info("Loading class definition file " + p.getFileName()); ClassDefinition result = null; for (ClassDefinition classDefinition : set) { if (classDefinition.getName().equalsIgnoreCase(key)) { result = new ObjectConverter().toObject(of, () -> classDefinition); break; } } if (result.getLevelProgression() != null && !(result.getLevelProgression() instanceof EmptyLevelProgression)) { result.getLevelProgression().setLevelMargins(result.getLevelProgression().initCurve()); } Set<String> expU = result.getExperienceSource().stream().map(String::toUpperCase).collect(Collectors.toSet()); result.setExperienceSources(expU); set.add(result); } } } catch (IOException e) { error("Could not read class file: ", e); } return set; }
ClassDefinitionDao { public Set<ClassDefinition> parseClassFiles(Path path) { Set<ClassDefinition> set = new HashSet<>(); try { Map<String, Path> stringPathMap = preloadClassDefs(path, set); for (Map.Entry<String, Path> stringPathEntry : stringPathMap.entrySet()) { String key = stringPathEntry.getKey(); Path p = stringPathEntry.getValue(); try (FileConfig of = FileConfig.of(p)) { of.load(); info("Loading class definition file " + p.getFileName()); ClassDefinition result = null; for (ClassDefinition classDefinition : set) { if (classDefinition.getName().equalsIgnoreCase(key)) { result = new ObjectConverter().toObject(of, () -> classDefinition); break; } } if (result.getLevelProgression() != null && !(result.getLevelProgression() instanceof EmptyLevelProgression)) { result.getLevelProgression().setLevelMargins(result.getLevelProgression().initCurve()); } Set<String> expU = result.getExperienceSource().stream().map(String::toUpperCase).collect(Collectors.toSet()); result.setExperienceSources(expU); set.add(result); } } } catch (IOException e) { error("Could not read class file: ", e); } return set; } }
ClassDefinitionDao { public Set<ClassDefinition> parseClassFiles(Path path) { Set<ClassDefinition> set = new HashSet<>(); try { Map<String, Path> stringPathMap = preloadClassDefs(path, set); for (Map.Entry<String, Path> stringPathEntry : stringPathMap.entrySet()) { String key = stringPathEntry.getKey(); Path p = stringPathEntry.getValue(); try (FileConfig of = FileConfig.of(p)) { of.load(); info("Loading class definition file " + p.getFileName()); ClassDefinition result = null; for (ClassDefinition classDefinition : set) { if (classDefinition.getName().equalsIgnoreCase(key)) { result = new ObjectConverter().toObject(of, () -> classDefinition); break; } } if (result.getLevelProgression() != null && !(result.getLevelProgression() instanceof EmptyLevelProgression)) { result.getLevelProgression().setLevelMargins(result.getLevelProgression().initCurve()); } Set<String> expU = result.getExperienceSource().stream().map(String::toUpperCase).collect(Collectors.toSet()); result.setExperienceSources(expU); set.add(result); } } } catch (IOException e) { error("Could not read class file: ", e); } return set; }  }
ClassDefinitionDao { public Set<ClassDefinition> parseClassFiles(Path path) { Set<ClassDefinition> set = new HashSet<>(); try { Map<String, Path> stringPathMap = preloadClassDefs(path, set); for (Map.Entry<String, Path> stringPathEntry : stringPathMap.entrySet()) { String key = stringPathEntry.getKey(); Path p = stringPathEntry.getValue(); try (FileConfig of = FileConfig.of(p)) { of.load(); info("Loading class definition file " + p.getFileName()); ClassDefinition result = null; for (ClassDefinition classDefinition : set) { if (classDefinition.getName().equalsIgnoreCase(key)) { result = new ObjectConverter().toObject(of, () -> classDefinition); break; } } if (result.getLevelProgression() != null && !(result.getLevelProgression() instanceof EmptyLevelProgression)) { result.getLevelProgression().setLevelMargins(result.getLevelProgression().initCurve()); } Set<String> expU = result.getExperienceSource().stream().map(String::toUpperCase).collect(Collectors.toSet()); result.setExperienceSources(expU); set.add(result); } } } catch (IOException e) { error("Could not read class file: ", e); } return set; }  Path getClassDirectory(); Set<ClassDefinition> parseClassFiles(Path path); void preloadClassConfig(Set<ClassDefinition> set, Map<String, Path> map, Path p, Config fileConfig); }
ClassDefinitionDao { public Set<ClassDefinition> parseClassFiles(Path path) { Set<ClassDefinition> set = new HashSet<>(); try { Map<String, Path> stringPathMap = preloadClassDefs(path, set); for (Map.Entry<String, Path> stringPathEntry : stringPathMap.entrySet()) { String key = stringPathEntry.getKey(); Path p = stringPathEntry.getValue(); try (FileConfig of = FileConfig.of(p)) { of.load(); info("Loading class definition file " + p.getFileName()); ClassDefinition result = null; for (ClassDefinition classDefinition : set) { if (classDefinition.getName().equalsIgnoreCase(key)) { result = new ObjectConverter().toObject(of, () -> classDefinition); break; } } if (result.getLevelProgression() != null && !(result.getLevelProgression() instanceof EmptyLevelProgression)) { result.getLevelProgression().setLevelMargins(result.getLevelProgression().initCurve()); } Set<String> expU = result.getExperienceSource().stream().map(String::toUpperCase).collect(Collectors.toSet()); result.setExperienceSources(expU); set.add(result); } } } catch (IOException e) { error("Could not read class file: ", e); } return set; }  Path getClassDirectory(); Set<ClassDefinition> parseClassFiles(Path path); void preloadClassConfig(Set<ClassDefinition> set, Map<String, Path> map, Path p, Config fileConfig);  }