Good day guys! I have a question: How better refactor this function? I show a list of plugins in JSF, and I should filter them. I added function "filterPlugins" but I have some questions: 1. Should we simplify block with conditional expression? 2. I reassign global variable "plugins" fo introduce my filter function (is it not bad practice?) Here some piece of my code: @NotNull @DataModel("plugins") List<Plugin> plugins; public void load() { plugins = pluginManager.getPlugins(); plugins = filterPlugins(searchParam); SortingUtil.sort(plugins, SortingUtil.SortType.ID_ASC); if (plugins.size() > 0) { if (plugin != null && plugins.contains(plugin)) { selectPlugin(plugin); } else { selectPlugin(plugins.get(0)); } } else { plugin = null; } } @SuppressWarnings("unchecked") private List<Plugin> filterPlugins(final String searchParam ){ return (List)Iterables.filter(plugins, new Predicate<Plugin>() { @Override public boolean apply(@Nullable Plugin plugin) { return plugin.getName().contains(searchParam) || plugin.getNetworkClasses().contains(searchParam) || plugin.getClassName().contains(searchParam); } }); }