This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 0f070c406d7 Remove useless YamlUsersConfigurationConverter (#29587)
0f070c406d7 is described below
commit 0f070c406d77f554fce14f20886b850f4acad87d
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Dec 29 06:57:25 2023 +0800
Remove useless YamlUsersConfigurationConverter (#29587)
---
.../converter/YamlUsersConfigurationConverter.java | 59 ----------------------
.../NewYamlAuthorityRuleConfigurationSwapper.java | 7 +--
.../YamlAuthorityRuleConfigurationSwapper.java | 7 +--
3 files changed, 8 insertions(+), 65 deletions(-)
diff --git
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/converter/YamlUsersConfigurationConverter.java
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/converter/YamlUsersConfigurationConverter.java
deleted file mode 100644
index 6f3f24bf94a..00000000000
---
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/converter/YamlUsersConfigurationConverter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.authority.converter;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.authority.yaml.config.YamlUserConfiguration;
-import org.apache.shardingsphere.authority.yaml.swapper.YamlUserSwapper;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.stream.Collectors;
-
-/**
- * Configuration converter for YAML Users content.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class YamlUsersConfigurationConverter {
-
- private static final YamlUserSwapper SWAPPER = new YamlUserSwapper();
-
- /**
- * Convert to ShardingSphere users.
- *
- * @param users users YAML content
- * @return ShardingSphere users
- */
- public static Collection<ShardingSphereUser>
convertToShardingSphereUser(final Collection<YamlUserConfiguration> users) {
- return
users.stream().map(SWAPPER::swapToObject).collect(Collectors.toList());
- }
-
- /**
- * Convert to YAML user configurations.
- *
- * @param users users YAML content
- * @return YAML user configurations
- */
- public static Collection<YamlUserConfiguration>
convertToYamlUserConfiguration(final Collection<ShardingSphereUser> users) {
- Collection<YamlUserConfiguration> result = new LinkedList<>();
-
users.stream().map(SWAPPER::swapToYamlConfiguration).forEach(result::add);
- return result;
- }
-}
diff --git
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java
index 62f61af847d..fd32eee62d1 100644
---
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java
+++
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/NewYamlAuthorityRuleConfigurationSwapper.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.authority.yaml.swapper;
import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.constant.AuthorityOrder;
-import
org.apache.shardingsphere.authority.converter.YamlUsersConfigurationConverter;
import
org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder;
import
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
@@ -43,6 +42,8 @@ import java.util.stream.Collectors;
*/
public final class NewYamlAuthorityRuleConfigurationSwapper implements
NewYamlGlobalRuleConfigurationSwapper<AuthorityRuleConfiguration> {
+ private final YamlUserSwapper userSwapper = new YamlUserSwapper();
+
private final YamlAlgorithmConfigurationSwapper algorithmSwapper = new
YamlAlgorithmConfigurationSwapper();
@Override
@@ -53,7 +54,7 @@ public final class NewYamlAuthorityRuleConfigurationSwapper
implements NewYamlGl
private YamlAuthorityRuleConfiguration swapToYamlConfiguration(final
AuthorityRuleConfiguration data) {
YamlAuthorityRuleConfiguration result = new
YamlAuthorityRuleConfiguration();
result.setPrivilege(algorithmSwapper.swapToYamlConfiguration(data.getAuthorityProvider()));
-
result.setUsers(YamlUsersConfigurationConverter.convertToYamlUserConfiguration(data.getUsers()));
+
result.setUsers(data.getUsers().stream().map(userSwapper::swapToYamlConfiguration).collect(Collectors.toList()));
result.setDefaultAuthenticator(data.getDefaultAuthenticator());
data.getAuthenticators().forEach((key, value) ->
result.getAuthenticators().put(key,
algorithmSwapper.swapToYamlConfiguration(value)));
return result;
@@ -72,7 +73,7 @@ public final class NewYamlAuthorityRuleConfigurationSwapper
implements NewYamlGl
}
private AuthorityRuleConfiguration swapToObject(final
YamlAuthorityRuleConfiguration yamlConfig) {
- Collection<ShardingSphereUser> users =
YamlUsersConfigurationConverter.convertToShardingSphereUser(yamlConfig.getUsers());
+ Collection<ShardingSphereUser> users =
yamlConfig.getUsers().stream().map(userSwapper::swapToObject).collect(Collectors.toList());
AlgorithmConfiguration provider =
algorithmSwapper.swapToObject(yamlConfig.getPrivilege());
if (null == provider) {
provider = new
DefaultAuthorityRuleConfigurationBuilder().build().getAuthorityProvider();
diff --git
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/YamlAuthorityRuleConfigurationSwapper.java
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/YamlAuthorityRuleConfigurationSwapper.java
index 4ede2fe52c4..828ffe4d0cd 100644
---
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/YamlAuthorityRuleConfigurationSwapper.java
+++
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/YamlAuthorityRuleConfigurationSwapper.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.authority.yaml.swapper;
import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.constant.AuthorityOrder;
-import
org.apache.shardingsphere.authority.converter.YamlUsersConfigurationConverter;
import
org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder;
import
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
@@ -37,13 +36,15 @@ import java.util.stream.Collectors;
*/
public final class YamlAuthorityRuleConfigurationSwapper implements
YamlRuleConfigurationSwapper<YamlAuthorityRuleConfiguration,
AuthorityRuleConfiguration> {
+ private final YamlUserSwapper userSwapper = new YamlUserSwapper();
+
private final YamlAlgorithmConfigurationSwapper algorithmSwapper = new
YamlAlgorithmConfigurationSwapper();
@Override
public YamlAuthorityRuleConfiguration swapToYamlConfiguration(final
AuthorityRuleConfiguration data) {
YamlAuthorityRuleConfiguration result = new
YamlAuthorityRuleConfiguration();
result.setPrivilege(algorithmSwapper.swapToYamlConfiguration(data.getAuthorityProvider()));
-
result.setUsers(YamlUsersConfigurationConverter.convertToYamlUserConfiguration(data.getUsers()));
+
result.setUsers(data.getUsers().stream().map(userSwapper::swapToYamlConfiguration).collect(Collectors.toList()));
result.setDefaultAuthenticator(data.getDefaultAuthenticator());
data.getAuthenticators().forEach((key, value) ->
result.getAuthenticators().put(key,
algorithmSwapper.swapToYamlConfiguration(value)));
return result;
@@ -51,7 +52,7 @@ public final class YamlAuthorityRuleConfigurationSwapper
implements YamlRuleConf
@Override
public AuthorityRuleConfiguration swapToObject(final
YamlAuthorityRuleConfiguration yamlConfig) {
- Collection<ShardingSphereUser> users =
YamlUsersConfigurationConverter.convertToShardingSphereUser(yamlConfig.getUsers());
+ Collection<ShardingSphereUser> users =
yamlConfig.getUsers().stream().map(userSwapper::swapToObject).collect(Collectors.toList());
AlgorithmConfiguration provider =
algorithmSwapper.swapToObject(yamlConfig.getPrivilege());
if (null == provider) {
provider = new
DefaultAuthorityRuleConfigurationBuilder().build().getAuthorityProvider();