Revision 28:a21c8a208bda

View differences:

src/main/java/cz/agents/alite/configreader/ConfigMap.java
93 93

  
94 94
    @Override
95 95
    public float getFloat(String key, float defaultValue) {
96
        Object o = getObjectOrNull(key);
97

  
98
        if (o == null || o instanceof Number == false) {
99
            return defaultValue;
100
        } else {
101
            return ((Number) o).floatValue();
102
        }
96
        return getNumber(key, defaultValue).floatValue();
103 97
    }
104 98

  
105 99
    @Override
......
109 103

  
110 104
    @Override
111 105
    public double getDouble(String key, double defaultValue) {
112
        Object o = getObjectOrNull(key);
113

  
114
        if (o == null || o instanceof Number == false) {
115
            return defaultValue;
116
        } else {
117
            return ((BigDecimal) o).doubleValue();
118
        }
106
        return getNumber(key, defaultValue).doubleValue();
119 107
    }
120 108

  
121 109
    @Override
src/test/java/cz/agents/alite/configreader/ConfigTest.java
251 251
        assertEquals(3, someInt);
252 252
    }
253 253

  
254
    @Test
255
    public void testDoubleWithDefaultWrittenAsInt() {
256
        double someIntAsDouble = testConfig.getDouble(getWholeKey("someInt"), SOME_DOUBLE);
257
        assertEquals(SOME_INT, someIntAsDouble, DOUBLE_DELTA);
258
    }
259

  
254 260
    private String getWholeKey(String name) {
255 261
        return "a.b."+name;
256 262
    }

Also available in: Unified diff