mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Remove Byte and Short support from beans for now
The right way to do these would be analogous to getInt, that is, with a getter on Config that checks the range and throws the right exception if the range is incorrect. But, I hesitate to add getByte, getShort, getByteList, getShortList all to Config, since they don't seem super useful. If we do want them though, they should be added to beans and to Config at the same time, so they are completely parallel to how Integer and Long work.
This commit is contained in:
parent
82fcfe3f5a
commit
4c9d5aae4f
@ -109,10 +109,6 @@ public class ConfigBeanImpl {
|
||||
private static Object getValueWithAutoConversion(Class parameterClass, Config config, String configPropName) {
|
||||
if (parameterClass == Boolean.class || parameterClass == boolean.class) {
|
||||
return config.getBoolean(configPropName);
|
||||
} else if (parameterClass == Byte.class || parameterClass == byte.class) {
|
||||
return Integer.valueOf(config.getInt(configPropName)).byteValue();
|
||||
} else if (parameterClass == Short.class || parameterClass == short.class) {
|
||||
return Integer.valueOf(config.getInt(configPropName)).shortValue();
|
||||
} else if (parameterClass == Integer.class || parameterClass == int.class) {
|
||||
return config.getInt(configPropName);
|
||||
} else if (parameterClass == Double.class || parameterClass == double.class) {
|
||||
@ -134,10 +130,6 @@ public class ConfigBeanImpl {
|
||||
private static ConfigValueType getValueTypeOrNull(Class<?> parameterClass) {
|
||||
if (parameterClass == Boolean.class || parameterClass == boolean.class) {
|
||||
return ConfigValueType.BOOLEAN;
|
||||
} else if (parameterClass == Byte.class || parameterClass == byte.class) {
|
||||
return ConfigValueType.NUMBER;
|
||||
} else if (parameterClass == Short.class || parameterClass == short.class) {
|
||||
return ConfigValueType.NUMBER;
|
||||
} else if (parameterClass == Integer.class || parameterClass == int.class) {
|
||||
return ConfigValueType.NUMBER;
|
||||
} else if (parameterClass == Double.class || parameterClass == double.class) {
|
||||
|
@ -4,10 +4,6 @@ package beanconfig;
|
||||
public class NumbersConfig {
|
||||
|
||||
|
||||
private byte byteVal;
|
||||
private Byte byteObj;
|
||||
private short shortVal;
|
||||
private Short shortObj;
|
||||
private int intVal;
|
||||
private Integer intObj;
|
||||
private long longVal;
|
||||
@ -63,36 +59,4 @@ public class NumbersConfig {
|
||||
public void setDoubleObj(Double doubleObj) {
|
||||
this.doubleObj = doubleObj;
|
||||
}
|
||||
|
||||
public byte getByteVal() {
|
||||
return byteVal;
|
||||
}
|
||||
|
||||
public void setByteVal(byte byteVal) {
|
||||
this.byteVal = byteVal;
|
||||
}
|
||||
|
||||
public Byte getByteObj() {
|
||||
return byteObj;
|
||||
}
|
||||
|
||||
public void setByteObj(Byte byteObj) {
|
||||
this.byteObj = byteObj;
|
||||
}
|
||||
|
||||
public short getShortVal() {
|
||||
return shortVal;
|
||||
}
|
||||
|
||||
public void setShortVal(short shortVal) {
|
||||
this.shortVal = shortVal;
|
||||
}
|
||||
|
||||
public Short getShortObj() {
|
||||
return shortObj;
|
||||
}
|
||||
|
||||
public void setShortObj(Short shortObj) {
|
||||
this.shortObj = shortObj;
|
||||
}
|
||||
}
|
||||
|
@ -74,10 +74,6 @@ class ConfigBeanFactoryTest extends TestUtils {
|
||||
def testCreateNumber() {
|
||||
val beanConfig: NumbersConfig = ConfigBeanFactory.create(loadConfig().getConfig("numbers"), classOf[NumbersConfig])
|
||||
assertNotNull(beanConfig)
|
||||
assertEquals(1: Byte, beanConfig.getByteVal)
|
||||
assertEquals(1: Byte, beanConfig.getByteObj)
|
||||
assertEquals(2: Short, beanConfig.getShortVal)
|
||||
assertEquals(2: Short, beanConfig.getShortObj)
|
||||
|
||||
assertEquals(3, beanConfig.getIntVal)
|
||||
assertEquals(3, beanConfig.getIntObj)
|
||||
|
Loading…
Reference in New Issue
Block a user