From 457855bb5cd3cd91ba98d5744af615fe0dbf9c52 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 27 Dec 2024 15:54:02 +0100 Subject: [PATCH] Use lambda expression --- .../samples/petclinic/genai/AIDataProvider.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-petclinic-genai-service/src/main/java/org/springframework/samples/petclinic/genai/AIDataProvider.java b/spring-petclinic-genai-service/src/main/java/org/springframework/samples/petclinic/genai/AIDataProvider.java index d29ff7a32..04f4e8b0f 100644 --- a/spring-petclinic-genai-service/src/main/java/org/springframework/samples/petclinic/genai/AIDataProvider.java +++ b/spring-petclinic-genai-service/src/main/java/org/springframework/samples/petclinic/genai/AIDataProvider.java @@ -24,11 +24,11 @@ public class AIDataProvider { private final VectorStore vectorStore; - private String ownersHostname = "http://customers-service/"; - + private final String ownersHostname = "http://customers-service/"; + private final WebClient webClient; - + public AIDataProvider(WebClient.Builder webClientBuilder, VectorStore vectorStore) { this.webClient = webClientBuilder.build(); this.vectorStore = vectorStore; @@ -54,12 +54,11 @@ public VetResponse getVets(VetRequest request) throws JsonProcessingException { } List topMatches = this.vectorStore.similaritySearch(sr); - List results = topMatches.stream().map(document -> document.getContent()).toList(); + List results = topMatches.stream().map(Document::getContent).toList(); return new VetResponse(results); } public AddedPetResponse addPetToOwner(AddPetRequest request) { - return new AddedPetResponse(webClient .post() .uri(ownersHostname + "owners/"+request.ownerId()+"/pets") @@ -73,7 +72,6 @@ public OwnerResponse addOwnerToPetclinic(OwnerRequest ownerRequest) { .uri(ownersHostname + "owners") .bodyValue(ownerRequest) .retrieve().bodyToMono(OwnerDetails.class).block()); - } }