/** * @param pattern the pattern to match * @param offset the offset where to start returning elements * @param nb the number of maximum element to return * @param extensions the extension collection to search in * @param forceUnique make sure returned elements are unique * @return the search result * @since 6.4.1 * @param <E> the type of element in the {@link Collection} */ public static <E extends Extension> CollectionIterableResult<E> searchInCollection( String pattern, int offset, int nb, Collection<E> extensions, boolean forceUnique) { ExtensionQuery query = new ExtensionQuery(pattern); query.setOffset(offset); query.setLimit(nb); return searchInCollection(query, extensions, forceUnique); }
/** * @param query the query * @param extensions the extension collection to search in * @param forceUnique make sure returned elements are unique * @return the search result * @since 7.0M2 * @param <E> the type of element in the {@link Collection} */ public static <E extends Extension> CollectionIterableResult<E> searchInCollection( ExtensionQuery query, Collection<E> extensions, boolean forceUnique) { List<E> result; // Filter if (StringUtils.isEmpty(query.getQuery())) { result = extensions instanceof List ? (List<E>) extensions : new ArrayList<E>(extensions); } else { result = filter(query.getQuery(), query.getFilters(), extensions, forceUnique); } // Sort sort(result, query.getSortClauses()); // Create result return RepositoryUtils.getIterableResult(query.getOffset(), query.getLimit(), result); }