diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 9bf229f627..ec5fedbf25 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -29,6 +29,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * Created by XiaXiang on 2017/3/27. @@ -199,18 +200,15 @@ public class PluginSearchManager implements AlphaFineSearchProvider { */ List parseDefaultPluginModel(List jsonObjects) { List pluginModels = new ArrayList<>(); + String version = "v" + ProductConstants.MAIN_VERSION; if (!Collections.isEmpty(jsonObjects)) { - jsonObjects.sort(PluginSearchManager::sortPluginByUploadTime); - int pluginModelsCount = 0; - String version = "v" + ProductConstants.MAIN_VERSION; - for (Map obj : jsonObjects) { - if (pluginModelsCount == DEFAULT_LIST_SIZE) { - break; - } - if (((Integer) obj.get(version)) == 1) { - pluginModels.add(getPluginModel(new JSONObject(obj), false)); - pluginModelsCount++; - } + jsonObjects = jsonObjects.stream() + .filter(o -> ((Integer) o.get(version)) == 1) + .sorted(PluginSearchManager::sortPluginByUploadTime) + .collect(Collectors.toList()); + int size = Math.min(DEFAULT_LIST_SIZE, jsonObjects.size()); + for (int i = 0; i < size; i++) { + pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); } } return pluginModels;