Now we are ready to implement more advance functionality. In our Repository Factory we override the query lookup strategy using our own implementation for FHIR queries (see the next section)
Strategy:
public class FHIRQueryLookupStrategy implements QueryLookupStrategy {
private final IGenericClient fhirClient;
public FHIRQueryLookupStrategy(IGenericClient fhirClient) {
this.fhirClient = fhirClient;
}
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory, NamedQueries namedQueries) {
return new FHIRQuery(method, metadata, factory, fhirClient);
}
}
Repository Factory:
public class FhirRepositoryFactory extends RepositoryFactorySupport {
private final IGenericClient fhirClient;
...
@Override
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(QueryLookupStrategy.Key key,
QueryMethodEvaluationContextProvider evaluationContextProvider) {
return Optional.of(new FHIRQueryLookupStrategy(fhirClient));
}
}
Query methods support

No we are implementing RepositoryQuery interface which has two methods:
execute() — executes the target method.
getQueryMethod() — returns a method metadata.
Inside the constructor we take general methods metadata and also parse parameter names (based on method name).