I have an code block:
public Builder withMultiValueMap(MultiValueMap<String, String> multiValueMap) {
...
withRespondentId(Long.valueOf(multiValueMap.getFirst("respondentId")));
...
return this;
}
Sometimes map can return null if no value for respondentId key. I can process it in old way using something like
String respondentId = multiValueMap.getFirst("respondentId");
withRespondentId(respondentId == null? null: Long.valueOf(respondentId));
...but I want do it better!
Is it possible simplify using java8 Optional or other stuff?