| 1 | package pl.zankowski.iextrading4j.client.properties; | |
| 2 | ||
| 3 | import java.io.IOException; | |
| 4 | import java.io.InputStream; | |
| 5 | import java.util.Properties; | |
| 6 | ||
| 7 | public class PropertiesReader { | |
| 8 | ||
| 9 | private static final String PROPERTIES_NAME = "iextrading.properties"; | |
| 10 | ||
| 11 | private static final PropertiesReader INSTANCE = new PropertiesReader(); | |
| 12 | ||
| 13 | private final Properties properties = new Properties(); | |
| 14 | ||
| 15 | public PropertiesReader() { | |
| 16 |
1
1. <init> : removed call to pl/zankowski/iextrading4j/client/properties/PropertiesReader::setDefaults → SURVIVED |
setDefaults(); |
| 17 | try (InputStream propertiesStream = PropertiesReader.class.getClassLoader() | |
| 18 | .getResourceAsStream(PROPERTIES_NAME)) { | |
| 19 | if (propertiesStream != null) { | |
| 20 |
1
1. <init> : removed call to java/util/Properties::load → NO_COVERAGE |
properties.load(propertiesStream); |
| 21 | } | |
| 22 | } catch (IOException e1) { | |
| 23 | // Whatever, we have defaults | |
| 24 | } | |
| 25 | } | |
| 26 | ||
| 27 | public static PropertiesReader getInstance() { | |
| 28 |
1
1. getInstance : replaced return value with null for pl/zankowski/iextrading4j/client/properties/PropertiesReader::getInstance → KILLED |
return INSTANCE; |
| 29 | } | |
| 30 | ||
| 31 | private void setDefaults() { | |
| 32 | for (final PropertyType propertyType : PropertyType.values()) { | |
| 33 | properties.setProperty(propertyType.name(), propertyType.getDefaultValue()); | |
| 34 | } | |
| 35 | } | |
| 36 | ||
| 37 | public String getString(final PropertyType propertyType) { | |
| 38 |
1
1. getString : negated conditional → SURVIVED |
if (propertyType == null) { |
| 39 |
1
1. getString : replaced return value with "" for pl/zankowski/iextrading4j/client/properties/PropertiesReader::getString → NO_COVERAGE |
return null; |
| 40 | } | |
| 41 |
1
1. getString : replaced return value with "" for pl/zankowski/iextrading4j/client/properties/PropertiesReader::getString → SURVIVED |
return properties.getProperty(propertyType.name()); |
| 42 | } | |
| 43 | ||
| 44 | public Boolean getBoolean(final PropertyType propertyType) { | |
| 45 |
2
1. getBoolean : replaced Boolean return with False for pl/zankowski/iextrading4j/client/properties/PropertiesReader::getBoolean → SURVIVED 2. getBoolean : replaced Boolean return with True for pl/zankowski/iextrading4j/client/properties/PropertiesReader::getBoolean → SURVIVED |
return Boolean.valueOf(getString(propertyType)); |
| 46 | } | |
| 47 | ||
| 48 | } | |
Mutations | ||
| 16 |
1.1 |
|
| 20 |
1.1 |
|
| 28 |
1.1 |
|
| 38 |
1.1 |
|
| 39 |
1.1 |
|
| 41 |
1.1 |
|
| 45 |
1.1 2.2 |