优化代码。

This commit is contained in:
zhouxy108 2024-05-28 09:41:07 +08:00
parent 33b271ddbe
commit 245c31bdce
3 changed files with 7 additions and 9 deletions

View File

@ -45,6 +45,8 @@
<optional>true</optional>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>

View File

@ -20,7 +20,6 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
@ -60,10 +59,9 @@ public class PagingAndSortingQueryParams {
public PagingAndSortingQueryParams(Map<String, String> sortableProperties) {
Preconditions.checkArgument(sortableProperties != null && !sortableProperties.isEmpty(),
"Sortable properties can not be empty.");
for (Entry<String, String> p : sortableProperties.entrySet()) {
Preconditions.checkArgument(StringUtils.isNotBlank(p.getKey()) && StringUtils.isNotBlank(p.getValue()),
"Property name must not be blank.");
}
sortableProperties.forEach((k, v) ->
Preconditions.checkArgument(StringUtils.isNotBlank(k) && StringUtils.isNotBlank(v),
"Property name must not be blank."));
this.sortableProperties = ImmutableMap.copyOf(sortableProperties);
}

View File

@ -124,10 +124,8 @@ class MenuList extends Menu {
}
static MenuList of(String parentMenuCode, String menuCode, String title, Iterable<Menu> children, int orderNum) {
MenuList instance = of(parentMenuCode, menuCode, title, orderNum);
for (Menu child : children) {
instance.addChild(child);
}
final MenuList instance = of(parentMenuCode, menuCode, title, orderNum);
children.forEach(instance::addChild);
return instance;
}