Class ItemSearchResult<T>

java.lang.Object
de.hybris.platform.integrationservices.search.ItemSearchResult<T>

public class ItemSearchResult<T> extends Object
Result of searching items in the platform. This result is immutable except it does not guarantee immutability of the items returned by getItems() method.
  • Method Details

    • createFrom

      public static <T> ItemSearchResult<T> createFrom(SearchResult<T> result)
      Creates new item search result instance from the specified Flexible Search result.
      Type Parameters:
      T - type of the items searched.
      Parameters:
      result - flexible search result.
      Returns:
      new item search result instance.
    • createWith

      public static <T> ItemSearchResult<T> createWith(List<T> items, int totalCount)
      Creates new item search result instance with total number of matching items existing in the platform.
      Type Parameters:
      T - type of the items searched.
      Parameters:
      items - items found. Usually in this scenario this is a subset of all items existing in the platform, which match the ItemSearchRequest.
      totalCount - total number of items persisted in the platform, which match the criteria specified by the ItemSearchRequest
      Returns:
      new item search result instance.
      See Also:
    • createWith

      public static <T> ItemSearchResult<T> createWith(List<T> items)
      Creates new item search result instance when total count of matching items is not needed.
      Type Parameters:
      T - type of the items searched
      Parameters:
      items - items found
      Returns:
      new item search result instance.
    • getItems

      public List<T> getItems()
      Retrieves items existing in the platform and matching the request conditions.
      Returns:
      all items matching the ItemSearchRequest conditions or a subset of all items in case of a paged request. When no items match the conditions, an empty list is returned.
    • getTotalCount

      public Optional<Integer> getTotalCount()
      Retrieves total number of items existing in the platform and matching the ItemSearchRequest conditions.
      Returns:
      number of items matching the conditions in the platform. This number may be greater than the number of items returned by getItems() method when PaginationParameters were used in the request. If count was not requested, then Optional.empty() is returned.
    • map

      public <R> ItemSearchResult<R> map(Function<T,R> f)
      Transforms this result into a result containing different kind of items.
      Type Parameters:
      R - type of the entries in the transformed result
      Parameters:
      f - a function to be applied to each item contained in this result
      Returns:
      a result containing entries, which were transformed from the original result by applying the specified function.