From 8696a0b8ccc58a58973fad2f595c4c5c51a33ec4 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 25 Oct 2023 23:21:03 +0200 Subject: [PATCH] [MINDEXER-205] Align them Make them both static helpers, as they have no logic. --- https://issues.apache.org/jira/browse/MINDEXER-205 --- .../RemoteRepositorySearchBackendFactory.java | 4 +++- .../maven/search/backend/smo/SmoSearchBackendFactory.java | 8 +++++--- .../backend/smo/internal/SmoSearchBackendImplTest.java | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/search-backend-remoterepository/src/main/java/org/apache/maven/search/backend/remoterepository/RemoteRepositorySearchBackendFactory.java b/search-backend-remoterepository/src/main/java/org/apache/maven/search/backend/remoterepository/RemoteRepositorySearchBackendFactory.java index 1f1f5010..b612f197 100644 --- a/search-backend-remoterepository/src/main/java/org/apache/maven/search/backend/remoterepository/RemoteRepositorySearchBackendFactory.java +++ b/search-backend-remoterepository/src/main/java/org/apache/maven/search/backend/remoterepository/RemoteRepositorySearchBackendFactory.java @@ -27,7 +27,7 @@ /** * The remote repository search backend factory. */ -public class RemoteRepositorySearchBackendFactory { +public final class RemoteRepositorySearchBackendFactory { public static final String BACKEND_ID = "search-rr"; public static final String CENTRAL_REPOSITORY_ID = "central"; @@ -38,6 +38,8 @@ public class RemoteRepositorySearchBackendFactory { public static final String RAO_RELEASES_URI = "https://repository.apache.org/content/repositories/releases/"; + private RemoteRepositorySearchBackendFactory() {} + /** * Creates "default" RR search backend against Maven Central suitable for most use cases. */ diff --git a/search-backend-smo/src/main/java/org/apache/maven/search/backend/smo/SmoSearchBackendFactory.java b/search-backend-smo/src/main/java/org/apache/maven/search/backend/smo/SmoSearchBackendFactory.java index 6ac6144a..dcb5679b 100644 --- a/search-backend-smo/src/main/java/org/apache/maven/search/backend/smo/SmoSearchBackendFactory.java +++ b/search-backend-smo/src/main/java/org/apache/maven/search/backend/smo/SmoSearchBackendFactory.java @@ -25,24 +25,26 @@ /** * The SMO search backend factory. */ -public class SmoSearchBackendFactory { +public final class SmoSearchBackendFactory { public static final String DEFAULT_BACKEND_ID = "central-smo"; public static final String DEFAULT_REPOSITORY_ID = "central"; public static final String DEFAULT_SMO_URI = "https://search.maven.org/solrsearch/select"; + private SmoSearchBackendFactory() {} + /** * Creates "default" SMO search backend suitable for most use cases. */ - public SmoSearchBackend createDefault() { + public static SmoSearchBackend createDefault() { return create(DEFAULT_BACKEND_ID, DEFAULT_REPOSITORY_ID, DEFAULT_SMO_URI, new Java11HttpClientTransport()); } /** * Creates SMO search backend using provided parameters. */ - public SmoSearchBackend create(String backendId, String repositoryId, String smoUri, Transport transport) { + public static SmoSearchBackend create(String backendId, String repositoryId, String smoUri, Transport transport) { return new SmoSearchBackendImpl(backendId, repositoryId, smoUri, transport); } } diff --git a/search-backend-smo/src/test/java/org/apache/maven/search/backend/smo/internal/SmoSearchBackendImplTest.java b/search-backend-smo/src/test/java/org/apache/maven/search/backend/smo/internal/SmoSearchBackendImplTest.java index 932bdac5..20649c5e 100644 --- a/search-backend-smo/src/test/java/org/apache/maven/search/backend/smo/internal/SmoSearchBackendImplTest.java +++ b/search-backend-smo/src/test/java/org/apache/maven/search/backend/smo/internal/SmoSearchBackendImplTest.java @@ -38,7 +38,7 @@ @Ignore("This is not a test, is more a showcase") public class SmoSearchBackendImplTest { - private final SmoSearchBackend backend = new SmoSearchBackendFactory().createDefault(); + private final SmoSearchBackend backend = SmoSearchBackendFactory.createDefault(); private void dumpSingle(AtomicInteger counter, List page) { for (Record record : page) {