日本語のみで絞り込む
2018/11/1 -That is, how can I get a map get to return a proper Optional ? ... How can I return a value while checking if a Java 8 Optional is present?
2024/11/9 -It allows you to apply a transformation function to an Optional object only if it contains a value. If the Optional is empty, map() simply ...
A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value.
2020/4/7 -With an Optional object, you can access the methods available to explicitly deal with the presence or absence of values, instead of having to ...
Use Optional for return types when absence is a valid result ; Use ofNullable() instead of of() unless you're 100% sure value is not null ; Chain operations using ...
2016/8/30 -If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result.
2015/10/30 -To transform the value of an Optional we can use the map method. Here's an example, again in the context of a unit test: @Test public void ...
2017/8/10 -You use a Map<String, Optional<String>> type, which communicates better that you have a map of potentially missing values (preventing nasty ...
2026/2/15 -The map method returns the result of the computation wrapped inside Optional. We then have to call an appropriate method on the returned ...
2024/12/15 -get() a value from Optional. To get a value out the optional you can use the get() method like this: 1 2, Optional<String> opt = Optional.of ...