@Test public void accept() { final Host bookmark = new Host(new TestProtocol(Scheme.http), "a"); assertTrue(new BookmarkSearchFilter("b a").accept(bookmark)); assertFalse(new BookmarkSearchFilter("b testa").accept(bookmark)); assertFalse(new BookmarkSearchFilter("b b").accept(bookmark)); assertTrue(new BookmarkSearchFilter("HTTP").accept(bookmark)); bookmark.setNickname("t"); assertTrue(new BookmarkSearchFilter("t").accept(bookmark)); assertFalse(new BookmarkSearchFilter("t2").accept(bookmark)); bookmark.setLabels(Collections.singleton("l")); assertTrue(new BookmarkSearchFilter("l").accept(bookmark)); assertFalse(new BookmarkSearchFilter("l2").accept(bookmark)); }
@Override public boolean accept(final Host bookmark) { final String[] elements = StringUtils.split(StringUtils.lowerCase(searchString, Locale.ROOT)); for(String search : elements) { if(StringUtils.lowerCase(BookmarkNameProvider.toString(bookmark), Locale.ROOT).contains(search)) { return true; } if(null != bookmark.getCredentials().getUsername()) { if(StringUtils.lowerCase(bookmark.getCredentials().getUsername(), Locale.ROOT).contains(search)) { return true; } } if(null != bookmark.getComment()) { if(StringUtils.lowerCase(bookmark.getComment(), Locale.ROOT).contains(search)) { return true; } } if(StringUtils.lowerCase(bookmark.getHostname(), Locale.ROOT).contains(search)) { return true; } for(String label : bookmark.getLabels()) { if(StringUtils.lowerCase(label, Locale.ROOT).contains(search)) { return true; } } } return false; }
BookmarkSearchFilter implements HostFilter { @Override public boolean accept(final Host bookmark) { final String[] elements = StringUtils.split(StringUtils.lowerCase(searchString, Locale.ROOT)); for(String search : elements) { if(StringUtils.lowerCase(BookmarkNameProvider.toString(bookmark), Locale.ROOT).contains(search)) { return true; } if(null != bookmark.getCredentials().getUsername()) { if(StringUtils.lowerCase(bookmark.getCredentials().getUsername(), Locale.ROOT).contains(search)) { return true; } } if(null != bookmark.getComment()) { if(StringUtils.lowerCase(bookmark.getComment(), Locale.ROOT).contains(search)) { return true; } } if(StringUtils.lowerCase(bookmark.getHostname(), Locale.ROOT).contains(search)) { return true; } for(String label : bookmark.getLabels()) { if(StringUtils.lowerCase(label, Locale.ROOT).contains(search)) { return true; } } } return false; } }
BookmarkSearchFilter implements HostFilter { @Override public boolean accept(final Host bookmark) { final String[] elements = StringUtils.split(StringUtils.lowerCase(searchString, Locale.ROOT)); for(String search : elements) { if(StringUtils.lowerCase(BookmarkNameProvider.toString(bookmark), Locale.ROOT).contains(search)) { return true; } if(null != bookmark.getCredentials().getUsername()) { if(StringUtils.lowerCase(bookmark.getCredentials().getUsername(), Locale.ROOT).contains(search)) { return true; } } if(null != bookmark.getComment()) { if(StringUtils.lowerCase(bookmark.getComment(), Locale.ROOT).contains(search)) { return true; } } if(StringUtils.lowerCase(bookmark.getHostname(), Locale.ROOT).contains(search)) { return true; } for(String label : bookmark.getLabels()) { if(StringUtils.lowerCase(label, Locale.ROOT).contains(search)) { return true; } } } return false; } BookmarkSearchFilter(final String searchString); }
BookmarkSearchFilter implements HostFilter { @Override public boolean accept(final Host bookmark) { final String[] elements = StringUtils.split(StringUtils.lowerCase(searchString, Locale.ROOT)); for(String search : elements) { if(StringUtils.lowerCase(BookmarkNameProvider.toString(bookmark), Locale.ROOT).contains(search)) { return true; } if(null != bookmark.getCredentials().getUsername()) { if(StringUtils.lowerCase(bookmark.getCredentials().getUsername(), Locale.ROOT).contains(search)) { return true; } } if(null != bookmark.getComment()) { if(StringUtils.lowerCase(bookmark.getComment(), Locale.ROOT).contains(search)) { return true; } } if(StringUtils.lowerCase(bookmark.getHostname(), Locale.ROOT).contains(search)) { return true; } for(String label : bookmark.getLabels()) { if(StringUtils.lowerCase(label, Locale.ROOT).contains(search)) { return true; } } } return false; } BookmarkSearchFilter(final String searchString); @Override boolean accept(final Host bookmark); }
BookmarkSearchFilter implements HostFilter { @Override public boolean accept(final Host bookmark) { final String[] elements = StringUtils.split(StringUtils.lowerCase(searchString, Locale.ROOT)); for(String search : elements) { if(StringUtils.lowerCase(BookmarkNameProvider.toString(bookmark), Locale.ROOT).contains(search)) { return true; } if(null != bookmark.getCredentials().getUsername()) { if(StringUtils.lowerCase(bookmark.getCredentials().getUsername(), Locale.ROOT).contains(search)) { return true; } } if(null != bookmark.getComment()) { if(StringUtils.lowerCase(bookmark.getComment(), Locale.ROOT).contains(search)) { return true; } } if(StringUtils.lowerCase(bookmark.getHostname(), Locale.ROOT).contains(search)) { return true; } for(String label : bookmark.getLabels()) { if(StringUtils.lowerCase(label, Locale.ROOT).contains(search)) { return true; } } } return false; } BookmarkSearchFilter(final String searchString); @Override boolean accept(final Host bookmark);  }