示例#1
0
  /**
   * Searches for a tag with the given ID.
   *
   * @param rootTag The tag where the search begins.
   * @param tagId The ID of the tag to search for.
   * @return The tag with the given ID or null if no such tag exists.
   */
  public static CTag findTag(final ITreeNode<CTag> rootTag, final int tagId) {
    for (final ITreeNode<CTag> c : BreadthFirstSorter.getSortedList(rootTag)) {
      if (tagId == c.getObject().getId()) {
        return c.getObject();
      }
    }

    return null;
  }
示例#2
0
  /**
   * Searches for the tags with a list of given IDs
   *
   * @param rootTag The tag where the search begins.
   * @param tagIds The list of tag IDs to search for.
   * @return A list of tags with the given IDs. Note that there is not necessarily a 1:1
   *     correspondence between the input list and the output list.
   */
  public static Collection<CTag> findTags(
      final ITreeNode<CTag> rootTag, final Collection<Integer> tagIds) {
    Preconditions.checkNotNull(tagIds, "IE00866: List argument can't be null");

    final HashSet<CTag> tags = new HashSet<CTag>();

    for (final ITreeNode<CTag> c : BreadthFirstSorter.getSortedList(rootTag)) {
      if (tagIds.contains(c.getObject().getId())) {
        tags.add(c.getObject());
      }
    }

    return tags;
  }