@Test public void testAliases() { assertThat(aliasesOf("app").size(), is(1)); assertThat(aliasesOf("app"), contains("APP")); assertThat(aliasesOf("app.name").size(), is(2)); assertThat(aliasesOf("app.name"), contains("app_name", "APP_NAME")); assertThat(aliasesOf("app/name").size(), is(2)); assertThat(aliasesOf("app/name"), contains("app_name", "APP_NAME")); assertThat(aliasesOf("app/camelCase").size(), is(2)); assertThat(aliasesOf("app/camelCase"), contains("app_camelCase", "APP_CAMELCASE")); assertThat(aliasesOf("app.qualified-name").size(), is(3)); assertThat(aliasesOf("app.qualified-name"), contains("app_qualified_dash_name", "APP_QUALIFIED_dash_NAME", "APP_QUALIFIED_DASH_NAME")); assertThat(aliasesOf("app/qualified-name").size(), is(3)); assertThat(aliasesOf("app/qualified-name"), contains("app_qualified_dash_name", "APP_QUALIFIED_dash_NAME", "APP_QUALIFIED_DASH_NAME")); assertThat(aliasesOf("app/qualified-camelCaseName").size(), is(3)); assertThat(aliasesOf("app/qualified-camelCaseName"), contains("app_qualified_dash_camelCaseName", "APP_QUALIFIED_dash_CAMELCASENAME", "APP_QUALIFIED_DASH_CAMELCASENAME")); assertThat(aliasesOf("app.page-size").size(), is(3)); assertThat(aliasesOf("app.page-size"), contains("app_page_dash_size", "APP_PAGE_dash_SIZE", "APP_PAGE_DASH_SIZE")); }
public static List<String> aliasesOf(final String key) { if (key != null && !key.isEmpty()) { if (key.indexOf(DASH_CHAR) < 0) { String alias = DISALLOWED_CHARS.matcher(key).replaceAll(UNDERSCORE); if (alias.equals(key)) { return singletonList(alias.toUpperCase()); } else { return asList(alias, alias.toUpperCase()); } } else { String baseAlias = DISALLOWED_CHARS_ALLOW_DASH.matcher(key).replaceAll(UNDERSCORE); String aliasLowerDash = DASH_PATTERN.matcher(baseAlias).replaceAll(DASH_ENCODING); String upperBaseAlias = baseAlias.toUpperCase(); String upperAliasLowerDash = DASH_PATTERN.matcher(upperBaseAlias).replaceAll(DASH_ENCODING); String upperAliasUpperDash = upperAliasLowerDash.toUpperCase(); return asList(aliasLowerDash, upperAliasLowerDash, upperAliasUpperDash); } } return Collections.emptyList(); }
EnvironmentVariableAliases { public static List<String> aliasesOf(final String key) { if (key != null && !key.isEmpty()) { if (key.indexOf(DASH_CHAR) < 0) { String alias = DISALLOWED_CHARS.matcher(key).replaceAll(UNDERSCORE); if (alias.equals(key)) { return singletonList(alias.toUpperCase()); } else { return asList(alias, alias.toUpperCase()); } } else { String baseAlias = DISALLOWED_CHARS_ALLOW_DASH.matcher(key).replaceAll(UNDERSCORE); String aliasLowerDash = DASH_PATTERN.matcher(baseAlias).replaceAll(DASH_ENCODING); String upperBaseAlias = baseAlias.toUpperCase(); String upperAliasLowerDash = DASH_PATTERN.matcher(upperBaseAlias).replaceAll(DASH_ENCODING); String upperAliasUpperDash = upperAliasLowerDash.toUpperCase(); return asList(aliasLowerDash, upperAliasLowerDash, upperAliasUpperDash); } } return Collections.emptyList(); } }
EnvironmentVariableAliases { public static List<String> aliasesOf(final String key) { if (key != null && !key.isEmpty()) { if (key.indexOf(DASH_CHAR) < 0) { String alias = DISALLOWED_CHARS.matcher(key).replaceAll(UNDERSCORE); if (alias.equals(key)) { return singletonList(alias.toUpperCase()); } else { return asList(alias, alias.toUpperCase()); } } else { String baseAlias = DISALLOWED_CHARS_ALLOW_DASH.matcher(key).replaceAll(UNDERSCORE); String aliasLowerDash = DASH_PATTERN.matcher(baseAlias).replaceAll(DASH_ENCODING); String upperBaseAlias = baseAlias.toUpperCase(); String upperAliasLowerDash = DASH_PATTERN.matcher(upperBaseAlias).replaceAll(DASH_ENCODING); String upperAliasUpperDash = upperAliasLowerDash.toUpperCase(); return asList(aliasLowerDash, upperAliasLowerDash, upperAliasUpperDash); } } return Collections.emptyList(); } private  EnvironmentVariableAliases(); }
EnvironmentVariableAliases { public static List<String> aliasesOf(final String key) { if (key != null && !key.isEmpty()) { if (key.indexOf(DASH_CHAR) < 0) { String alias = DISALLOWED_CHARS.matcher(key).replaceAll(UNDERSCORE); if (alias.equals(key)) { return singletonList(alias.toUpperCase()); } else { return asList(alias, alias.toUpperCase()); } } else { String baseAlias = DISALLOWED_CHARS_ALLOW_DASH.matcher(key).replaceAll(UNDERSCORE); String aliasLowerDash = DASH_PATTERN.matcher(baseAlias).replaceAll(DASH_ENCODING); String upperBaseAlias = baseAlias.toUpperCase(); String upperAliasLowerDash = DASH_PATTERN.matcher(upperBaseAlias).replaceAll(DASH_ENCODING); String upperAliasUpperDash = upperAliasLowerDash.toUpperCase(); return asList(aliasLowerDash, upperAliasLowerDash, upperAliasUpperDash); } } return Collections.emptyList(); } private  EnvironmentVariableAliases(); static List<String> aliasesOf(final String key); }
EnvironmentVariableAliases { public static List<String> aliasesOf(final String key) { if (key != null && !key.isEmpty()) { if (key.indexOf(DASH_CHAR) < 0) { String alias = DISALLOWED_CHARS.matcher(key).replaceAll(UNDERSCORE); if (alias.equals(key)) { return singletonList(alias.toUpperCase()); } else { return asList(alias, alias.toUpperCase()); } } else { String baseAlias = DISALLOWED_CHARS_ALLOW_DASH.matcher(key).replaceAll(UNDERSCORE); String aliasLowerDash = DASH_PATTERN.matcher(baseAlias).replaceAll(DASH_ENCODING); String upperBaseAlias = baseAlias.toUpperCase(); String upperAliasLowerDash = DASH_PATTERN.matcher(upperBaseAlias).replaceAll(DASH_ENCODING); String upperAliasUpperDash = upperAliasLowerDash.toUpperCase(); return asList(aliasLowerDash, upperAliasLowerDash, upperAliasUpperDash); } } return Collections.emptyList(); } private  EnvironmentVariableAliases(); static List<String> aliasesOf(final String key);  }