1   package com.atlassian.user.search;
2   
3   import com.atlassian.user.search.page.Pager;
4   import com.atlassian.user.search.page.PagerFactory;
5   
6   import java.util.*;
7   
8   public class DefaultSearchResult<T> implements SearchResult<T>
9   {
10      private Map<String, Pager<T>> repoKeyToResults = new LinkedHashMap<String, Pager<T>>();
11  
12      public DefaultSearchResult(){}
13  
14      public DefaultSearchResult(Pager<T> result, String repositoryKey)
15      {
16          addToResults(repositoryKey, result);
17      }
18  
19      public Pager<T> pager()
20      {
21          return PagerFactory.getPager(new ArrayList<Pager<T>>(repoKeyToResults.values()));
22      }
23  
24      public void addToResults(String repositoryKey, Pager<T> pager)
25      {
26          repoKeyToResults.put(repositoryKey, pager);
27      }
28  
29      public Pager<T> pager(String repoKey)
30      {
31          return repoKeyToResults.get(repoKey);
32      }
33  
34      /**
35       * @return a list of {@link String} objects indcating the repositories with results in this object.
36       */
37      public Set<String> repositoryKeyset()
38      {
39          return repoKeyToResults.keySet();
40      }
41  }