Skip to content
Permalink
Browse files

Improved: Inline getAppBarWebInfos(String, Comparator, String) privat…

…e method (OFBIZ-10606)

The comparator argument of this method was always ‘null’.  Use
‘java.util.TreeMap()’ constructor in the inlined function which is
equivalent to passing ‘null’ to ‘java.util.TreeMap(Comparator)’.



git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1854432 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Feb 26, 2019
1 parent 6be4f5e commit 9d209d919a549f51325173963df39e8055697776
Showing with 2 additions and 20 deletions.
  1. +2 −20 framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppCache.java
@@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.TreeMap;
@@ -71,7 +70,7 @@ public WebAppCache(Supplier<Collection<ComponentConfig>>supplier) {
* @return the corresponding web applications information
*/
public List<WebappInfo> getAppBarWebInfos(String serverName) {
return getAppBarWebInfos(serverName, null, null);
return getAppBarWebInfos(serverName, null);
}

/**
@@ -87,23 +86,6 @@ public WebAppCache(Supplier<Collection<ComponentConfig>>supplier) {
* @throws NullPointerException when {@code serverName} is {@code null}
*/
public List<WebappInfo> getAppBarWebInfos(String serverName, String menuName) {
return getAppBarWebInfos(serverName, null, menuName);
}

/**
* Retrieves the web applications information that must be visible inside
* the menu {@code menuName} in the context of the server {@code serverName}.
* <p>
* When an empty string or {@code null} is used for {@code menuName},
* all the web application information corresponding to {@code serverName} are matched.
*
* @param serverName the name of server to match
* @param comp the comparator used for ordering the results
* @param menuName the name of the menu to match
* @return the corresponding web applications information
* @throws NullPointerException when {@code serverName} is {@code null}
*/
private List<WebappInfo> getAppBarWebInfos(String serverName, Comparator<? super String> comp, String menuName) {
String serverWebAppsKey = serverName + menuName;
List<WebappInfo> webInfos = null;
synchronized (serverWebApps) {
@@ -121,7 +103,7 @@ public WebAppCache(Supplier<Collection<ComponentConfig>>supplier) {
}
})
// Keep only one WebappInfo per title (the last appearing one).
.collect(() -> new TreeMap<>(comp),
.collect(TreeMap::new,
(acc, wInfo) -> {
String key = UtilValidate.isNotEmpty(wInfo.position) ? wInfo.position : wInfo.title;
acc.put(key, wInfo);

0 comments on commit 9d209d9

Please sign in to comment.
You can’t perform that action at this time.