I was surprised by Optional.ofNullable method. Some day I wrote a function that supposed to return an Optional:
private Optional
smth like this should work
Optional.ofNullable(insight.getValues()).map(vals -> vals.get(0)).map(v -> v.getValue())
well, according to the sample code given, as #extractFirstValueFrom do not contain neither @Nullable nor checks for null like Guava's checkNotNull(), let's assume that insight is always something. thus wrapping Optional.ofNullable(insight.getValues()) into Option would not result with NPE. then call chain of transformations is composed (each results with Optional) that lead to result Optional that might be either Some or None.