@Test public void filterToBdbProps() throws Exception { Properties properties = new Properties(); properties.setProperty("com.addthis.some.prop", "super awesome"); properties.setProperty("je.sharedCache", "True"); Properties filteredProperties = BdbUtils.filterToBdbProps(properties); Assert.assertEquals("filtered properties should be reduced by one", 1, filteredProperties.size()); Assert.assertEquals("je.sharedCache should be the one kept", "je.sharedCache", filteredProperties.keys().nextElement()); }
static Properties filterToBdbProps(Properties properties) { Properties filteredProperties = new Properties(); try (Stream<Object> stream = properties.keySet().stream()) { stream.filter(key -> key instanceof String) .map(key -> (String) key) .filter(EnvironmentParams.SUPPORTED_PARAMS::containsKey) .forEach(key -> { String baseValue = properties.getProperty(key); if (NUMBER_UNIT.matcher(baseValue).matches()) { String convertedValue = Long.toString(Size.parse(baseValue).toBytes()); filteredProperties.setProperty(key, convertedValue); } else { filteredProperties.setProperty(key, baseValue); } }); } return filteredProperties; }
BdbUtils { static Properties filterToBdbProps(Properties properties) { Properties filteredProperties = new Properties(); try (Stream<Object> stream = properties.keySet().stream()) { stream.filter(key -> key instanceof String) .map(key -> (String) key) .filter(EnvironmentParams.SUPPORTED_PARAMS::containsKey) .forEach(key -> { String baseValue = properties.getProperty(key); if (NUMBER_UNIT.matcher(baseValue).matches()) { String convertedValue = Long.toString(Size.parse(baseValue).toBytes()); filteredProperties.setProperty(key, convertedValue); } else { filteredProperties.setProperty(key, baseValue); } }); } return filteredProperties; } }
BdbUtils { static Properties filterToBdbProps(Properties properties) { Properties filteredProperties = new Properties(); try (Stream<Object> stream = properties.keySet().stream()) { stream.filter(key -> key instanceof String) .map(key -> (String) key) .filter(EnvironmentParams.SUPPORTED_PARAMS::containsKey) .forEach(key -> { String baseValue = properties.getProperty(key); if (NUMBER_UNIT.matcher(baseValue).matches()) { String convertedValue = Long.toString(Size.parse(baseValue).toBytes()); filteredProperties.setProperty(key, convertedValue); } else { filteredProperties.setProperty(key, baseValue); } }); } return filteredProperties; } private  BdbUtils(); }
BdbUtils { static Properties filterToBdbProps(Properties properties) { Properties filteredProperties = new Properties(); try (Stream<Object> stream = properties.keySet().stream()) { stream.filter(key -> key instanceof String) .map(key -> (String) key) .filter(EnvironmentParams.SUPPORTED_PARAMS::containsKey) .forEach(key -> { String baseValue = properties.getProperty(key); if (NUMBER_UNIT.matcher(baseValue).matches()) { String convertedValue = Long.toString(Size.parse(baseValue).toBytes()); filteredProperties.setProperty(key, convertedValue); } else { filteredProperties.setProperty(key, baseValue); } }); } return filteredProperties; } private  BdbUtils();  }
BdbUtils { static Properties filterToBdbProps(Properties properties) { Properties filteredProperties = new Properties(); try (Stream<Object> stream = properties.keySet().stream()) { stream.filter(key -> key instanceof String) .map(key -> (String) key) .filter(EnvironmentParams.SUPPORTED_PARAMS::containsKey) .forEach(key -> { String baseValue = properties.getProperty(key); if (NUMBER_UNIT.matcher(baseValue).matches()) { String convertedValue = Long.toString(Size.parse(baseValue).toBytes()); filteredProperties.setProperty(key, convertedValue); } else { filteredProperties.setProperty(key, baseValue); } }); } return filteredProperties; } private  BdbUtils();   }