You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/08/04 02:48:59 UTC
[shardingsphere] branch master updated: Remove PersistRepositoryConfigurationYamlSwapperFactory.findInstance() (#19844)
This is an automated email from the ASF dual-hosted git repository.
yx9o pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 4df3a2d5c52 Remove PersistRepositoryConfigurationYamlSwapperFactory.findInstance() (#19844)
4df3a2d5c52 is described below
commit 4df3a2d5c52ecaadbf7bdd5107447a3efadceac3
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Aug 4 10:48:53 2022 +0800
Remove PersistRepositoryConfigurationYamlSwapperFactory.findInstance() (#19844)
* Fix checkstyle for EventListenerFixture
* Remove PersistRepositoryConfigurationYamlSwapperFactory.findInstance()
---
.../PersistRepositoryConfigurationYamlSwapperEngine.java | 2 +-
.../PersistRepositoryConfigurationYamlSwapperFactory.java | 12 ------------
...PersistRepositoryConfigurationYamlSwapperFactoryTest.java | 11 -----------
3 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperEngine.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperEngine.java
index 29b866072d4..513997c30ad 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperEngine.java
@@ -46,6 +46,6 @@ public final class PersistRepositoryConfigurationYamlSwapperEngine {
*/
@SuppressWarnings("unchecked")
public PersistRepositoryConfiguration swapToObject(final String type, final YamlPersistRepositoryConfiguration yamlConfig) {
- return PersistRepositoryConfigurationYamlSwapperFactory.findInstance(type).map(optional -> (PersistRepositoryConfiguration) optional.swapToObject(yamlConfig)).orElse(null);
+ return (PersistRepositoryConfiguration) PersistRepositoryConfigurationYamlSwapperFactory.getInstance(type).swapToObject(yamlConfig);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactory.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactory.java
index dc13916b3ad..5a3e7019574 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactory.java
@@ -22,8 +22,6 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.util.Optional;
-
/**
* Persist repository configuration YAML swapper factory.
*/
@@ -44,14 +42,4 @@ public final class PersistRepositoryConfigurationYamlSwapperFactory {
public static PersistRepositoryConfigurationYamlSwapper getInstance(final String type) {
return TypedSPIRegistry.getRegisteredService(PersistRepositoryConfigurationYamlSwapper.class, type);
}
-
- /**
- * Find instance of persist repository configuration YAML swapper.
- *
- * @param type swapper type
- * @return found instance
- */
- public static Optional<PersistRepositoryConfigurationYamlSwapper> findInstance(final String type) {
- return TypedSPIRegistry.findRegisteredService(PersistRepositoryConfigurationYamlSwapper.class, type);
- }
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactoryTest.java
index b399d1bbd5b..5358855c458 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactoryTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactoryTest.java
@@ -20,11 +20,8 @@ package org.apache.shardingsphere.infra.yaml.config.swapper.mode;
import org.apache.shardingsphere.infra.yaml.config.swapper.fixture.PersistRepositoryConfigurationYamlSwapperFixture;
import org.junit.Test;
-import java.util.Optional;
-
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
public final class PersistRepositoryConfigurationYamlSwapperFactoryTest {
@@ -32,12 +29,4 @@ public final class PersistRepositoryConfigurationYamlSwapperFactoryTest {
public void assertGetInstance() {
assertThat(PersistRepositoryConfigurationYamlSwapperFactory.getInstance("Fixture"), instanceOf(PersistRepositoryConfigurationYamlSwapperFixture.class));
}
-
- @SuppressWarnings("rawtypes")
- @Test
- public void assertFindInstance() {
- Optional<PersistRepositoryConfigurationYamlSwapper> actual = PersistRepositoryConfigurationYamlSwapperFactory.findInstance("Fixture");
- assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(PersistRepositoryConfigurationYamlSwapperFixture.class));
- }
}