/** * Looks up the given key in the given map, converting the result into * a string, using the default value if the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a string, or defaultValue if the * original value is null, the map is null or the string conversion fails */ public static <K> String getString(final Map<? super K, ?> map, final K key, final String defaultValue) { String answer = getString(map, key); if (answer == null) { answer = defaultValue; } return answer; }
private UriParametersParser getUriParametersParser(Module module) { RoutingParameterSet parametersType = RoutingParameterSet.DEFAULT; Map<String, Object> moduleSystemParameters = systemParameters.getModuleParameters() .getOrDefault(module.getName(), Collections.emptyMap()); String defaultHost = (String) moduleSystemParameters.getOrDefault(parametersType.host, null); int defaultPort = (Integer) moduleSystemParameters.getOrDefault(parametersType.port, 0); String routePath = (String) module.getParameters() .get(SupportedParameters.ROUTE_PATH); String defaultDomain = getDefaultDomain(parametersType, moduleSystemParameters); String protocol = MapUtils.getString(moduleSystemParameters, SupportedParameters.PROTOCOL); return new UriParametersParser(portBasedRouting, defaultHost, defaultDomain, defaultPort, routePath, includeProtocol(), protocol); }
public List<String> getIdleApplicationUris(Module module, List<Map<String, Object>> propertiesList) { RoutingParameterSet parametersType = RoutingParameterSet.DEFAULT_IDLE; Map<String, Object> moduleSystemParameters = systemParameters.getModuleParameters() .getOrDefault(module.getName(), Collections.emptyMap()); String defaultHost = (String) moduleSystemParameters.getOrDefault(parametersType.host, null); int defaultPort = (Integer) moduleSystemParameters.getOrDefault(parametersType.port, 0); String defaultRoutePath = (String) module.getParameters() .get(SupportedParameters.ROUTE_PATH); String defaultDomain = getDefaultDomain(parametersType, moduleSystemParameters); String protocol = MapUtils.getString(moduleSystemParameters, SupportedParameters.PROTOCOL); return new IdleUriParametersParser(portBasedRouting, defaultHost, defaultDomain, defaultPort, defaultRoutePath, includeProtocol(), protocol).parse(propertiesList); }