Skip to content

Commit 80554c0

Browse files
committed
fix: 修复剩余69个CI提示的代码风格错误问题
1 parent 73809dd commit 80554c0

File tree

9 files changed

+185
-69
lines changed

9 files changed

+185
-69
lines changed

shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.web.server.ServerWebExchange;
3434
import reactor.core.publisher.Mono;
3535
import java.util.List;
36+
import java.util.Objects;
3637

3738
/**
3839
* abstract shenyu plugin please extends.
@@ -71,7 +72,6 @@ public Mono<Void> execute(final ServerWebExchange exchange, final ShenyuPluginCh
7172
final String pluginName = named();
7273
final String path = getRawPath(exchange);
7374

74-
7575
List<PluginData> pluginDataList = pluginDataDecisionMaker.getData(pluginName);
7676
if (CollectionUtils.isEmpty(pluginDataList) || !pluginDataDecisionMaker.shouldContinue(pluginDataList.get(0))) {
7777
return pluginDataDecisionMaker.handleEmpty(pluginName, exchange, chain);
@@ -82,8 +82,8 @@ public Mono<Void> execute(final ServerWebExchange exchange, final ShenyuPluginCh
8282
return selectorDataDecisionMaker.handleEmpty(pluginName, exchange, chain);
8383
}
8484

85-
SelectorData selectorData = selectorDataDecisionMaker.matchData(exchange,pluginName, selectorDataList, path, null);
86-
if (selectorData == null) {
85+
SelectorData selectorData = selectorDataDecisionMaker.matchData(exchange, pluginName, selectorDataList, path, null);
86+
if (Objects.isNull(selectorData)) {
8787
return selectorDataDecisionMaker.handleEmpty(pluginName, exchange, chain);
8888
}
8989

@@ -92,8 +92,6 @@ public Mono<Void> execute(final ServerWebExchange exchange, final ShenyuPluginCh
9292
return doExecute(exchange, chain, selectorData, defaultRuleData(selectorData));
9393
}
9494

95-
96-
9795
List<RuleData> ruleDataList = ruleDataDecisionMaker.getData(selectorData.getId());
9896
if (CollectionUtils.isEmpty(ruleDataList)) {
9997
return ruleDataDecisionMaker.handleEmpty(pluginName, exchange, chain);
@@ -105,8 +103,8 @@ public Mono<Void> execute(final ServerWebExchange exchange, final ShenyuPluginCh
105103
return doExecute(exchange, chain, selectorData, rule);
106104
}
107105

108-
RuleData ruleData = ruleDataDecisionMaker.matchData(exchange,named(), ruleDataList, path, selectorData);
109-
if (ruleData == null) {
106+
RuleData ruleData = ruleDataDecisionMaker.matchData(exchange, named(), ruleDataList, path, selectorData);
107+
if (Objects.isNull(ruleData)) {
110108
return ruleDataDecisionMaker.handleEmpty(pluginName, exchange, chain);
111109
}
112110

shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/maker/AbstractMatchDecisionMaker.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package org.apache.shenyu.plugin.base.maker;
219

320
import org.apache.shenyu.common.dto.BaseData;
@@ -10,6 +27,7 @@
1027

1128
/**
1229
* Abstract base class for making match decisions in plugins using the Template Method pattern.
30+
*
1331
* <p>
1432
* This class provides a template for processing data matching logic in plugins. Subclasses are expected
1533
* to implement the abstract methods to define specific behaviors for handling empty data, matching data,
@@ -24,15 +42,18 @@
2442
* @param <T> the type of data to be matched, extending {@link BaseData}
2543
*/
2644
public abstract class AbstractMatchDecisionMaker<T extends BaseData> {
27-
private final DataProvider<T> dataProvider;
45+
2846
protected static final String URI_CONDITION_TYPE = "uri";
2947

48+
private final DataProvider<T> dataProvider;
49+
50+
3051
/**
3152
* Constructs an AbstractMatchDecisionMaker with the specified data provider.
3253
*
3354
* @param dataProvider the data provider used to retrieve data for matching
3455
*/
35-
protected AbstractMatchDecisionMaker(DataProvider<T> dataProvider) {
56+
protected AbstractMatchDecisionMaker(final DataProvider<T> dataProvider) {
3657
this.dataProvider = dataProvider;
3758
}
3859

@@ -42,7 +63,7 @@ protected AbstractMatchDecisionMaker(DataProvider<T> dataProvider) {
4263
* @param key the key used to retrieve data
4364
* @return a list of data objects associated with the key
4465
*/
45-
public List<T> getData(String key) {
66+
public List<T> getData(final String key) {
4667
return dataProvider.getData(key);
4768
}
4869

shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/maker/PluginDataDecisionMaker.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package org.apache.shenyu.plugin.base.maker;
219

320
import org.apache.shenyu.common.dto.PluginData;
@@ -61,7 +78,7 @@ public PluginDataDecisionMaker() {
6178
* @return a Mono indicating completion of the empty handler operation
6279
*/
6380
@Override
64-
public Mono<Void> handleEmpty(String pluginName, ServerWebExchange exchange, ShenyuPluginChain chain) {
81+
public Mono<Void> handleEmpty(final String pluginName, final ServerWebExchange exchange, final ShenyuPluginChain chain) {
6582
return chain.execute(exchange);
6683
}
6784

@@ -85,7 +102,7 @@ public Mono<Void> handleEmpty(String pluginName, ServerWebExchange exchange, She
85102
* @return the matched PluginData, or null if the data list is empty
86103
*/
87104
@Override
88-
public PluginData matchData(ServerWebExchange exchange, String dataName, List<PluginData> dataList, String path, SelectorData selectorData) {
105+
public PluginData matchData(final ServerWebExchange exchange, final String dataName, final List<PluginData> dataList, final String path, final SelectorData selectorData) {
89106
return dataList.isEmpty() ? null : dataList.get(0);
90107
}
91108

@@ -104,7 +121,7 @@ public PluginData matchData(ServerWebExchange exchange, String dataName, List<Pl
104121
* @return true if the plugin is enabled and should continue processing, false otherwise
105122
*/
106123
@Override
107-
public boolean shouldContinue(PluginData data) {
108-
return data != null && data.getEnabled();
124+
public boolean shouldContinue(final PluginData data) {
125+
return data.getEnabled();
109126
}
110127
}

shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/maker/RuleDataDecisionMaker.java

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package org.apache.shenyu.plugin.base.maker;
219

320
import org.apache.commons.collections4.CollectionUtils;
@@ -20,8 +37,12 @@
2037
import org.apache.shenyu.plugin.base.trie.ShenyuTrieNode;
2138
import org.springframework.web.server.ServerWebExchange;
2239
import reactor.core.publisher.Mono;
23-
24-
import java.util.*;
40+
import java.util.Collection;
41+
import java.util.Collections;
42+
import java.util.Comparator;
43+
import java.util.List;
44+
import java.util.Map;
45+
import java.util.Objects;
2546
import java.util.stream.Collectors;
2647

2748
import static org.apache.shenyu.plugin.api.ShenyuPlugin.LOG;
@@ -58,6 +79,7 @@
5879
public class RuleDataDecisionMaker extends AbstractMatchDecisionMaker<RuleData> {
5980

6081
private ShenyuConfig.RuleMatchCache ruleMatchConfig;
82+
6183
private ShenyuTrie ruleTrie;
6284

6385
/**
@@ -86,7 +108,7 @@ public RuleDataDecisionMaker() {
86108
* @return a Mono indicating completion of the empty handler operation
87109
*/
88110
@Override
89-
public Mono<Void> handleEmpty(String pluginName, ServerWebExchange exchange, ShenyuPluginChain chain) {
111+
public Mono<Void> handleEmpty(final String pluginName, final ServerWebExchange exchange, final ShenyuPluginChain chain) {
90112
return chain.execute(exchange);
91113
}
92114

@@ -111,7 +133,7 @@ public Mono<Void> handleEmpty(String pluginName, ServerWebExchange exchange, She
111133
* @return the matched RuleData, or null if no suitable rule is found
112134
*/
113135
@Override
114-
public RuleData matchData(ServerWebExchange exchange, String ruleName, List<RuleData> dataList, String path, SelectorData selectorData) {
136+
public RuleData matchData(final ServerWebExchange exchange, final String ruleName, final List<RuleData> dataList, final String path, final SelectorData selectorData) {
115137
return dataList.isEmpty() ? trieMatchRule(exchange, ruleName, selectorData, path) : dataList.get(0);
116138
}
117139

@@ -126,9 +148,10 @@ public RuleData matchData(ServerWebExchange exchange, String ruleName, List<Rule
126148
* @param data the rule data to evaluate for continuation
127149
* @return true if the rule is enabled and should continue processing, false otherwise
128150
*/
151+
129152
@Override
130-
public boolean shouldContinue(RuleData data) {
131-
return data != null && data.getEnabled();
153+
public boolean shouldContinue(final RuleData data) {
154+
return data.getEnabled();
132155
}
133156

134157
/**
@@ -167,7 +190,7 @@ private void initCacheConfig() {
167190
* @param path the request path to match
168191
* @return the matched RuleData, or null if no match is found or trie matching is disabled
169192
*/
170-
private RuleData trieMatchRule(final ServerWebExchange exchange, String ruleName, final SelectorData selectorData, final String path) {
193+
private RuleData trieMatchRule(final ServerWebExchange exchange, final String ruleName, final SelectorData selectorData, final String path) {
171194
if (!ruleMatchConfig.getTrie().getEnabled()) {
172195
return null;
173196
}

shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/maker/SelectorDataDecisionMaker.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package org.apache.shenyu.plugin.base.maker;
219

320
import org.apache.commons.collections4.CollectionUtils;
@@ -21,7 +38,12 @@
2138
import org.springframework.web.server.ServerWebExchange;
2239
import reactor.core.publisher.Mono;
2340

24-
import java.util.*;
41+
import java.util.Collection;
42+
import java.util.Collections;
43+
import java.util.Comparator;
44+
import java.util.List;
45+
import java.util.Map;
46+
import java.util.Objects;
2547
import java.util.stream.Collectors;
2648

2749
import static org.apache.shenyu.plugin.api.ShenyuPlugin.LOG;
@@ -53,6 +75,7 @@
5375
public class SelectorDataDecisionMaker extends AbstractMatchDecisionMaker<SelectorData> {
5476

5577
private ShenyuConfig.SelectorMatchCache selectorMatchConfig;
78+
5679
private ShenyuTrie selectorTrie;
5780

5881
/**
@@ -78,7 +101,7 @@ public SelectorDataDecisionMaker() {
78101
* @return a Mono indicating completion of the empty handling operation
79102
*/
80103
@Override
81-
public Mono<Void> handleEmpty(String pluginName, ServerWebExchange exchange, ShenyuPluginChain chain) {
104+
public Mono<Void> handleEmpty(final String pluginName, final ServerWebExchange exchange, final ShenyuPluginChain chain) {
82105
return chain.execute(exchange);
83106
}
84107

@@ -107,7 +130,7 @@ public Mono<Void> handleEmpty(String pluginName, ServerWebExchange exchange, She
107130
*
108131
*/
109132
@Override
110-
public SelectorData matchData(ServerWebExchange exchange, String pluginName, List<SelectorData> dataList, String path, SelectorData selectorData) {
133+
public SelectorData matchData(final ServerWebExchange exchange, final String pluginName, final List<SelectorData> dataList, final String path, final SelectorData selectorData) {
111134
return dataList.isEmpty() ? trieMatchSelector(exchange, pluginName, path) : dataList.get(0);
112135
}
113136

@@ -123,8 +146,8 @@ public SelectorData matchData(ServerWebExchange exchange, String pluginName, Lis
123146
* false otherwise
124147
*/
125148
@Override
126-
public boolean shouldContinue(SelectorData data) {
127-
return data != null && data.getEnabled() && data.getContinued();
149+
public boolean shouldContinue(final SelectorData data) {
150+
return data.getEnabled() && data.getContinued();
128151
}
129152

130153
/**
@@ -282,7 +305,7 @@ private SelectorData manyMatchSelector(final List<SelectorData> filterCollectors
282305
* @param selectorData the selector data to cache
283306
* @param selectorMatchConfig the cache configuration parameters
284307
*/
285-
private void cacheSelectorData(final String path, final SelectorData selectorData, ShenyuConfig.SelectorMatchCache selectorMatchConfig) {
308+
private void cacheSelectorData(final String path, final SelectorData selectorData, final ShenyuConfig.SelectorMatchCache selectorMatchConfig) {
286309
if (Boolean.FALSE.equals(selectorMatchConfig.getCache().getEnabled()) || Objects.isNull(selectorData)
287310
|| Boolean.TRUE.equals(selectorData.getMatchRestful())) {
288311
return;

shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/provider/DataProvider.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
package org.apache.shenyu.plugin.base.provider;
219

320
import java.util.List;
421

522
/**
623
* A generic interface for providing data based on a given key.
7-
* <p>
8-
* Implementations of this interface are responsible for retrieving a list of data items
9-
* of type {@code T} associated with the specified key. This can be used in plugin systems
10-
* or other contexts where data needs to be fetched dynamically.
11-
*
12-
* @param <T> Names of various data types
13-
14-
/**
15-
* A generic interface for providing data based on a given key.
16-
* <p>
17-
* Implementations of this interface are responsible for retrieving a list of data items
18-
* of type {@code T} associated with the specified key. This can be used in plugin systems
19-
* or other contexts where data needs to be fetched dynamically.
2024
*
2125
* @param <T> the type of data provided by this provider
2226
*/

0 commit comments

Comments
 (0)