@Override public Object val(final String path) throws InvalidValuePathException, NoSuchElementException { if(path == null || path.isEmpty()) { return node; } final int sepPos = path.indexOf(pathSep); if(sepPos == 0 || sepPos == path.length() - 1) { throw new InvalidValuePathException(path); } if(sepPos > 0) { final String key = path.substring(0, sepPos); final String subPath = path.substring(sepPos + 1); final Object child = node.get(key); if(child instanceof Config) { try { return ((Config) child).val(subPath); } catch(final InvalidValuePathException e) { throw new InvalidValuePathException(key + pathSep + e.path()); } catch(final NoSuchElementException e) { throw new NoSuchElementException(key + pathSep + e.getMessage()); } } else { throw new NoSuchElementException(path); } } else { return node.get(path); } }
throw new InvalidValuePathException(key + pathSep + e.path()); } catch(final InvalidValueTypeException e) { throw new InvalidValueTypeException(
private static Config applyArgsToConfig( final String[] args, final Config config, final String initialStepId) { try { argsWithAliases(args, config).forEach(config::val); } catch (final IllegalArgumentNameException e) { final String formattedAllCliArgs = allCliArgs(config.schema(), config.pathSep()).stream() .collect(Collectors.joining("\n", "\t", "")); Loggers.ERR.fatal( "Invalid argument: \"{}\"\nThe list of all possible args:\n{}", e.getMessage(), formattedAllCliArgs); } catch (final InvalidValuePathException e) { Loggers.ERR.fatal("Invalid configuration option: \"{}\"", e.path()); } catch (final InvalidValueTypeException e) { Loggers.ERR.fatal( "Invalid configuration value type for the option \"{}\", expected: {}, " + "actual: {}", e.path(), e.expectedType(), e.actualType()); } checkAndSetStepId(config, initialStepId); Arrays.stream(args).forEach(Loggers.CLI::info); return config; }
putBranch(key, (Map<String, Object>) schemaVal, val); } catch(final InvalidValuePathException e) { throw new InvalidValuePathException(key + pathSep + e.path()); } catch(final InvalidValueTypeException e) { throw new InvalidValueTypeException( putLeaf(key, (Class) schemaVal, val); } catch(final InvalidValuePathException e) { throw new InvalidValuePathException(key + pathSep + e.path()); } catch(final InvalidValueTypeException e) { throw new InvalidValueTypeException(