removed optional specific function
This commit is contained in:
parent
c4431dadf5
commit
a0079d22d2
|
@ -31,17 +31,6 @@ public class StringToIntConverter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Integer> convertStringToIntUsingOptional(String input){
|
|
||||||
Optional<Integer> parsedInt;
|
|
||||||
try {
|
|
||||||
parsedInt = Optional.of(Integer.parseInt(input));
|
|
||||||
} catch (Exception e) {
|
|
||||||
// log or handle the error
|
|
||||||
parsedInt = Optional.empty();
|
|
||||||
}
|
|
||||||
return parsedInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
int convertStringToIntUsingNumberUtils(String input, Integer defaultValue){
|
int convertStringToIntUsingNumberUtils(String input, Integer defaultValue){
|
||||||
return NumberUtils.toInt(input, defaultValue);
|
return NumberUtils.toInt(input, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ class stringToIntConverter {
|
||||||
testData.forEach(data -> {
|
testData.forEach(data -> {
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerParseInt(data.input).orElse(Integer.MIN_VALUE));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerParseInt(data.input).orElse(Integer.MIN_VALUE));
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input).orElse(Integer.MIN_VALUE));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input).orElse(Integer.MIN_VALUE));
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingOptional(data.input).orElse(Integer.MIN_VALUE));
|
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerDecode(data.input).orElse(Integer.MIN_VALUE));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerDecode(data.input).orElse(Integer.MIN_VALUE));
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingNumberUtils(data.input,Integer.MIN_VALUE ));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingNumberUtils(data.input,Integer.MIN_VALUE ));
|
||||||
});
|
});
|
||||||
|
@ -37,7 +36,6 @@ class stringToIntConverter {
|
||||||
testData.forEach(data -> {
|
testData.forEach(data -> {
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerParseInt(data.input).orElse(Integer.MIN_VALUE));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerParseInt(data.input).orElse(Integer.MIN_VALUE));
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input).orElse(Integer.MIN_VALUE));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input).orElse(Integer.MIN_VALUE));
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingOptional(data.input).orElse(Integer.MIN_VALUE));
|
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingNumberUtils(data.input, Integer.MIN_VALUE));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingNumberUtils(data.input, Integer.MIN_VALUE));
|
||||||
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerDecode(data.input).orElse(Integer.MIN_VALUE));
|
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerDecode(data.input).orElse(Integer.MIN_VALUE));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue