T10: PwzRegistrySource with PwzLookupClient [checkpoint]

This commit is contained in:
Artur Kruszewski
2026-07-08 23:12:00 +02:00
parent 387e2617b8
commit a8bdaf4cae
32 changed files with 227 additions and 60 deletions
@@ -0,0 +1,8 @@
package com.developx.szpitale.ingest.source;
import java.util.List;
@FunctionalInterface
public interface PwzLookupClient {
List<String> query(String fullName);
}
@@ -0,0 +1,31 @@
package com.developx.szpitale.ingest.source;
import java.util.List;
import java.util.Optional;
public class PwzRegistrySource {
private final PwzLookupClient client;
public PwzRegistrySource(PwzLookupClient client) {
this.client = client;
}
public Optional<String> lookupPwz(String fullName) {
if (client == null || fullName == null || fullName.isBlank()) {
return Optional.empty();
}
List<String> results = client.query(fullName);
if (results == null || results.isEmpty()) {
return Optional.empty();
}
if (results.size() == 1) {
return Optional.of(results.get(0));
}
return Optional.empty();
}
}