Пример #1
0
  public ArrayList<Pojo> getResults(String query) {
    query = StringNormalizer.normalize(query);

    ArrayList<Pojo> results = new ArrayList<>();

    for (AliasPojo entry : pojos) {
      if (entry.alias.startsWith(query)) {
        // Retrieve the AppPojo from AppProvider, being careful not to create any side effect
        // (default behavior is to alter displayName, which is not what we want)
        Pojo appPojo = appProvider.findById(entry.app, false);
        // Only add if default AppProvider is not already displaying it
        if (appPojo != null && !appPojo.nameNormalized.contains(query)) {
          appPojo.displayName =
              appPojo.name
                  + " <small>("
                  + entry.alias.replaceFirst("(?i)(" + Pattern.quote(query) + ")", "{$1}")
                  + ")</small>";
          appPojo.relevance = 10;
          results.add(appPojo);
        }
      }
    }

    return results;
  }
Пример #2
0
  public Pojo findById(String id) {

    for (Pojo pojo : pojos) {
      if (pojo.id.equals(id)) {
        pojo.displayName = pojo.name;
        return pojo;
      }
    }

    return null;
  }