Skip to content

Commit

Permalink
Refactor data filtering in RelevancyEvaluator
Browse files Browse the repository at this point in the history
Replace Objects::nonNull and instanceof checks with StringUtils::hasText
for more efficient and cleaner content filtering. This change simplifies
the stream operation in the getContent method, improving readability
and potentially performance.
  • Loading branch information
alexcheng1982 authored and Mark Pollack committed Sep 24, 2024
1 parent 202148d commit 2ecffc1
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.springframework.util.StringUtils;

public class RelevancyEvaluator implements Evaluator {

Expand Down Expand Up @@ -57,9 +57,7 @@ protected String doGetSupportingData(EvaluationRequest evaluationRequest) {
List<Content> data = evaluationRequest.getDataList();
return data.stream()
.map(Content::getContent)
.filter(Objects::nonNull)
.filter(c -> c instanceof String)
.map(Object::toString)
.filter(StringUtils::hasText)
.collect(Collectors.joining(System.lineSeparator()));
}

Expand Down

0 comments on commit 2ecffc1

Please sign in to comment.