I'm curious about a usage of Optional
.
With following code snippet,
public List<Some> read(
@QueryParam("first_result") @Min(0)
final Integer firstResult,
@QueryParam("max_results") @Min(0)
final Integer maxResults) {
// ...
if (firstResult != null) {
query.setFirstResult(firstResult);
}
// ...
}
When I change the code like this,
ofNullable(firstResult).ifPresent(v -> query.setFirstResult(v));
ofNullable
obviously creates a redundant object?