...
There is one simple rules that applies to all code and can often be used to decide between several coding solutions:.
Description | Bad | Good |
---|---|---|
Optional<String> optionalResponseBody = Optional.ofNullable(responseEntity.getBody()) .filter(Predicate.not(String::isBlank)); return (optionalResponseBody.isPresent()) ? convert(optionalResponseBody.get()) : Collections.emptyList(); | String responseBody = responseEntity.getBody(); if (responseBody == null || responseBody.isBlank()) { return Collections.emptyList(); } return convert(responseBody); |
...