private static ImmutableMap<String, String> parseAlternates(IniFile config) { if (!config.contains(ALTERNATES_SECTION)) { return ImmutableMap.of(); } Map<String, String> alternates = new HashMap<>(); for (Entry<String, String> entry : config.section(ALTERNATES_SECTION).asMap().entrySet()) { alternates.put(entry.getKey(), entry.getValue()); alternates.putIfAbsent(entry.getKey().toUpperCase(Locale.ENGLISH), entry.getValue()); } return ImmutableMap.copyOf(alternates); }
/** * Gets a single section of this INI file. * <p> * This returns the section associated with the specified name. * If the section does not exist an exception is thrown. * * @param name the section name * @return the INI file section * @throws IllegalArgumentException if the section does not exist */ public PropertySet section(String name) { ArgChecker.notNull(name, "name"); if (contains(name) == false) { throw new IllegalArgumentException("Unknown INI file section: " + name); } return sectionMap.get(name); }
private static ImmutableList<Pair<Pattern, String>> parseLenientPatterns(IniFile config) { if (!config.contains(LENIENT_PATTERNS_SECTION)) { return ImmutableList.of(); } List<Pair<Pattern, String>> alternates = new ArrayList<>(); for (Entry<String, String> entry : config.section(LENIENT_PATTERNS_SECTION).asMap().entrySet()) { alternates.add(Pair.of(Pattern.compile(entry.getKey(), Pattern.CASE_INSENSITIVE), entry.getValue())); } return ImmutableList.copyOf(alternates); }
Class<R> enumType) { if (!config.contains(TYPES_SECTION)) { return ImmutableList.of();
Class<R> enumType) { if (!config.contains(PROVIDERS_SECTION)) { return ImmutableList.of();
for (ResourceLocator resource : resources) { IniFile file = IniFile.of(resource.getCharSource()); if (file.contains(CHAIN_SECTION)) { PropertySet chainSection = file.section(CHAIN_SECTION);
ImmutableMap.of("section", PropertySet.of(keyValues1), "name", PropertySet.of(keyValues2))); assertEquals(test.contains("section"), true); assertEquals(test.section("section"), PropertySet.of(keyValues1)); assertEquals(test.section("section").contains("c"), true); assertEquals(test.section("section").asMultimap(), ImmutableListMultimap.of("c", "x", "b", "y", "a", "z")); assertEquals(test.contains("name"), true); assertEquals(test.section("name"), PropertySet.of(keyValues2)); assertEquals(test.section("name").contains("a"), true); assertEquals(test.section("name").asMultimap(), ImmutableListMultimap.of("a", "m", "b", "n")); assertEquals(test.contains("unknown"), false); assertThrowsIllegalArg(() -> test.section("unknown")); assertEquals(test.section("section").valueList("unknown"), ImmutableList.of());