From 093b3281fba1847e86f42e08e4ac96579d1dc5b9 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 4 Oct 2024 15:54:57 +0100 Subject: [PATCH] MNT-24637 PMD fixes. --- .../rest/api/impl/FavouritesImpl.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/remote-api/src/main/java/org/alfresco/rest/api/impl/FavouritesImpl.java b/remote-api/src/main/java/org/alfresco/rest/api/impl/FavouritesImpl.java index 0774beeec2..6f2898e4a3 100644 --- a/remote-api/src/main/java/org/alfresco/rest/api/impl/FavouritesImpl.java +++ b/remote-api/src/main/java/org/alfresco/rest/api/impl/FavouritesImpl.java @@ -40,8 +40,6 @@ import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; @@ -91,8 +89,6 @@ import org.alfresco.util.Pair; */ public class FavouritesImpl implements Favourites { - private static final Log logger = LogFactory.getLog(FavouritesImpl.class); - private static final List ALLOWED_INCLUDES = List.of(PARAM_INCLUDE_PROPERTIES, PARAM_INCLUDE_ASPECTNAMES, PARAM_INCLUDE_ALLOWABLEOPERATIONS); private People people; @@ -141,7 +137,7 @@ public class FavouritesImpl implements Favourites private Target getTarget(PersonFavourite personFavourite, Parameters parameters) { - Target target = null; + Target target; NodeRef nodeRef = personFavourite.getNodeRef(); Type type = personFavourite.getType(); if (type.equals(Type.FILE)) @@ -183,12 +179,12 @@ public class FavouritesImpl implements Favourites final List paramsInclude = parameters.getInclude(); if (!Collections.disjoint(paramsInclude, ALLOWED_INCLUDES)) { - final List includes = ALLOWED_INCLUDES.stream().filter(a -> paramsInclude.contains(a)).collect(Collectors.toList()); + final List includes = ALLOWED_INCLUDES.stream().filter(paramsInclude::contains).collect(Collectors.toList()); // get node representation with only properties included Node node = nodes.getFolderOrDocument(personFavourite.getNodeRef(), null, null, includes, null); // Create a map from node properties excluding properties already in this Favorite Map filteredNodeProperties = filterProps(node.getProperties(), EXCLUDED_PROPS); - if (filteredNodeProperties.size() > 0 && paramsInclude.contains(PARAM_INCLUDE_PROPERTIES)) + if (!filteredNodeProperties.isEmpty() && paramsInclude.contains(PARAM_INCLUDE_PROPERTIES)) { fav.setProperties(filteredNodeProperties); } @@ -217,7 +213,7 @@ public class FavouritesImpl implements Favourites private CollectionWithPagingInfo wrap(Paging paging, PagingResults personFavourites, Parameters parameters) { final List page = personFavourites.getPage(); - final List list = new AbstractList() { + final List list = new AbstractList<>() { @Override public Favourite get(int index) { @@ -371,7 +367,7 @@ public class FavouritesImpl implements Favourites List> sortProps = getSortProps(parameters); - final Set filteredByClientQuery = new HashSet(); + final Set filteredByClientQuery = new HashSet<>(); Set filterTypes = FavouritesService.Type.ALL_FILTER_TYPES; // Default all // filterType is of the form 'target.' @@ -389,7 +385,7 @@ public class FavouritesImpl implements Favourites { if (filteredByClient != null) { - int idx = filteredByClient.lastIndexOf("/"); + int idx = filteredByClient.lastIndexOf('/'); if (idx == -1 || idx == filteredByClient.length()) { throw new InvalidArgumentException(); @@ -404,7 +400,7 @@ public class FavouritesImpl implements Favourites } }); - if (filteredByClientQuery.size() > 0) + if (!filteredByClientQuery.isEmpty()) { filterTypes = filteredByClientQuery; } @@ -438,7 +434,7 @@ public class FavouritesImpl implements Favourites { List> sortProps = new ArrayList<>(); List sortCols = parameters.getSorting(); - if ((sortCols != null) && (sortCols.size() > 0)) + if (sortCols != null && !sortCols.isEmpty()) { for (SortColumn sortCol : sortCols) { @@ -451,7 +447,7 @@ public class FavouritesImpl implements Favourites { throw new InvalidArgumentException("Invalid sort field: " + sortCol.column); } - sortProps.add(new Pair<>(sortField, (sortCol.asc ? Boolean.TRUE : Boolean.FALSE))); + sortProps.add(new Pair<>(sortField, sortCol.asc ? Boolean.TRUE : Boolean.FALSE)); } } else