Skip to content

Commit

Permalink
remove guava usage from java code (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbartl-pv authored Nov 5, 2024
1 parent f8ef2bf commit 004d9ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageManager;
import com.day.cq.wcm.api.components.ComponentContext;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
Expand Down Expand Up @@ -115,7 +113,7 @@ public final Collection<ImageList.ListItem> getListItems() {
}
}

return ImmutableList.copyOf(imageListItems);
return Collections.unmodifiableList(imageListItems);
}

@Override
Expand Down Expand Up @@ -227,20 +225,19 @@ protected java.util.List<Resource> findPageComponentResources(final Page page, f
return componentResources;
}

final Map<String, String> params = ImmutableMap.<String, String>builder().
put(PathPredicateEvaluator.PATH, page.getContentResource().getPath()).
put(TypePredicateEvaluator.TYPE, JcrConstants.NT_UNSTRUCTURED).
put(JcrPropertyPredicateEvaluator.PROPERTY, JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY).
put(JcrPropertyPredicateEvaluator.PROPERTY + "." + JcrPropertyPredicateEvaluator.VALUE, slingResourceType).
put(PredicateConverter.GROUP_PARAMETER_PREFIX + "." + PredicateGroup.PARAM_LIMIT, String.valueOf(limit)).
put(PredicateConverter.GROUP_PARAMETER_PREFIX + "." + PredicateGroup.PARAM_GUESS_TOTAL, "true").
put(Predicate.ORDER_BY, "@jcr:path").
put(Predicate.ORDER_BY + "." + Predicate.PARAM_SORT , Predicate.SORT_ASCENDING).
build();
Map<String, String> params = new HashMap<>();
params.put(PathPredicateEvaluator.PATH, page.getContentResource().getPath());
params.put(TypePredicateEvaluator.TYPE, JcrConstants.NT_UNSTRUCTURED);
params.put(JcrPropertyPredicateEvaluator.PROPERTY, JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY);
params.put(JcrPropertyPredicateEvaluator.PROPERTY + "." + JcrPropertyPredicateEvaluator.VALUE, slingResourceType);
params.put(PredicateConverter.GROUP_PARAMETER_PREFIX + "." + PredicateGroup.PARAM_LIMIT, String.valueOf(limit));
params.put(PredicateConverter.GROUP_PARAMETER_PREFIX + "." + PredicateGroup.PARAM_GUESS_TOTAL, "true");
params.put(Predicate.ORDER_BY, "@jcr:path");
params.put(Predicate.ORDER_BY + "." + Predicate.PARAM_SORT , Predicate.SORT_ASCENDING);

final long start = System.currentTimeMillis();

final Iterator<Resource> resources = queryBuilder.createQuery(PredicateGroup.create(params),
final Iterator<Resource> resources = queryBuilder.createQuery(PredicateGroup.create(Collections.unmodifiableMap(params)),
request.getResourceResolver().adaptTo(Session.class)).getResult().getResources();

// Handle QueryBuilder's leakingResourceResolver; Make sure to close it manually.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

import com.adobe.aem.guides.wknd.core.models.Byline;
import com.adobe.cq.wcm.core.components.models.Image;
import com.google.common.collect.ImmutableList;

import static org.mockito.Mockito.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -76,11 +76,10 @@ public void testGetName() {

@Test
public void testGetOccupations() {
List<String> expected = new ImmutableList.Builder<String>()
.add("Blogger")
.add("Photographer")
.add("YouTuber")
.build();
List<String> expected = new ArrayList<>();
expected.add("Blogger");
expected.add("Photographer");
expected.add("YouTuber");

ctx.currentResource("/content/byline");
Byline byline = ctx.request().adaptTo(Byline.class);
Expand Down

0 comments on commit 004d9ef

Please sign in to comment.