IniReader { public boolean getBoolean(String key, boolean defaultValue) { Optional<String> stringOptional = Optional.ofNullable(values.get(key)); Optional<Boolean> booleanOptional = stringOptional.filter(s -> s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false")).map(s -> s.equalsIgnoreCase("true")); return booleanOptional.orElse(defaultValue); } IniReader(String fileName, SolFileReader reader);  IniReader(BufferedReader reader); static void write(String fileName, Object... keysVals); String getString(String key, String defaultValue); int getInt(String key, int defaultValue); boolean getBoolean(String key, boolean defaultValue); float getFloat(String key, float defaultValue);  }
@Test public void testGetBoolean() { assertFalse(iniReader.getBoolean("asdfghjk", false)); assertTrue(iniReader.getBoolean("asdfghjk", true)); assertTrue(iniReader.getBoolean("trueBooleanKey", false)); assertTrue(iniReader.getBoolean("anotherTrueBooleanKey", false)); assertFalse(iniReader.getBoolean("falseBooleanKey", true)); assertFalse(iniReader.getBoolean("anotherFalseBooleanKey", true)); assertFalse(iniReader.getBoolean("invalidBooleanKey", false)); assertTrue(iniReader.getBoolean("invalidBooleanKey", true)); }