I am converting a Optional<String> to Integer by .map(Integer::parseInt). Is there a way to avoid NumberFormatException if string can't be parsed as int?
I want to avoid try/catch statement for this.
I am converting a Optional<String> to Integer by .map(Integer::parseInt). Is there a way to avoid NumberFormatException if string can't be parsed as int?
I want to avoid try/catch statement for this.
Using Google Guava Ints.tryParse
map(Ints::tryParse)