コード例 #1
0
  public boolean hasBooksForPattern(String pattern) {
    if (pattern == null || pattern.length() == 0) {
      return false;
    }
    pattern = pattern.toLowerCase();

    for (Book b : books()) {
      if (b.matches(pattern)) {
        return true;
      }
    }
    return false;
  }
コード例 #2
0
  public List<Book> booksForPattern(String pattern) {
    if (pattern == null || pattern.length() == 0) {
      return Collections.emptyList();
    }
    pattern = pattern.toLowerCase();

    final LinkedList<Book> filtered = new LinkedList<Book>();
    for (Book b : books()) {
      if (b.matches(pattern)) {
        filtered.add(b);
      }
    }
    return filtered;
  }