@Test public void filterContacts() throws Exception { Contact unknown1 = createContact(NEW); Contact unknown2 = createContact(NEW); Contact known = createContact(ALL); Contact ignored = createContact(IGNORED); List<Contact> contacts = Arrays.asList(unknown1, unknown2, known, ignored); controller = getController(); assertThat(controller.filteredContacts(contacts, NEW), containsInAnyOrder(unknown1, unknown2)); assertThat(controller.filteredContacts(contacts, ALL), containsInAnyOrder(known, unknown1, unknown2)); assertThat(controller.filteredContacts(contacts, IGNORED), containsInAnyOrder(ignored)); }
List<Contact> filteredContacts(Collection<Contact> contacts, ContactsFilter filter) { return contacts.stream().filter(contact -> { switch (filter) { case ALL: return !contact.isIgnored() && (contact.getStatus() == Contact.ContactStatus.NORMAL || contact.getStatus() == Contact.ContactStatus.UNKNOWN); case NEW: return !contact.isIgnored() && contact.getStatus() == Contact.ContactStatus.UNKNOWN; case IGNORED: return contact.isIgnored(); } return false; }).collect(Collectors.toList()); }
ContactController extends AbstractController implements Initializable, EntityObserver { List<Contact> filteredContacts(Collection<Contact> contacts, ContactsFilter filter) { return contacts.stream().filter(contact -> { switch (filter) { case ALL: return !contact.isIgnored() && (contact.getStatus() == Contact.ContactStatus.NORMAL || contact.getStatus() == Contact.ContactStatus.UNKNOWN); case NEW: return !contact.isIgnored() && contact.getStatus() == Contact.ContactStatus.UNKNOWN; case IGNORED: return contact.isIgnored(); } return false; }).collect(Collectors.toList()); } }
ContactController extends AbstractController implements Initializable, EntityObserver { List<Contact> filteredContacts(Collection<Contact> contacts, ContactsFilter filter) { return contacts.stream().filter(contact -> { switch (filter) { case ALL: return !contact.isIgnored() && (contact.getStatus() == Contact.ContactStatus.NORMAL || contact.getStatus() == Contact.ContactStatus.UNKNOWN); case NEW: return !contact.isIgnored() && contact.getStatus() == Contact.ContactStatus.UNKNOWN; case IGNORED: return contact.isIgnored(); } return false; }).collect(Collectors.toList()); }  }
ContactController extends AbstractController implements Initializable, EntityObserver { List<Contact> filteredContacts(Collection<Contact> contacts, ContactsFilter filter) { return contacts.stream().filter(contact -> { switch (filter) { case ALL: return !contact.isIgnored() && (contact.getStatus() == Contact.ContactStatus.NORMAL || contact.getStatus() == Contact.ContactStatus.UNKNOWN); case NEW: return !contact.isIgnored() && contact.getStatus() == Contact.ContactStatus.UNKNOWN; case IGNORED: return contact.isIgnored(); } return false; }).collect(Collectors.toList()); }  @Override void initialize(URL location, ResourceBundle resources); void loadContacts(); @Override void update(); void openContactMenu(MouseEvent event); }
ContactController extends AbstractController implements Initializable, EntityObserver { List<Contact> filteredContacts(Collection<Contact> contacts, ContactsFilter filter) { return contacts.stream().filter(contact -> { switch (filter) { case ALL: return !contact.isIgnored() && (contact.getStatus() == Contact.ContactStatus.NORMAL || contact.getStatus() == Contact.ContactStatus.UNKNOWN); case NEW: return !contact.isIgnored() && contact.getStatus() == Contact.ContactStatus.UNKNOWN; case IGNORED: return contact.isIgnored(); } return false; }).collect(Collectors.toList()); }  @Override void initialize(URL location, ResourceBundle resources); void loadContacts(); @Override void update(); void openContactMenu(MouseEvent event); public ContactMenuController contactMenuController; public PopOver popOver; }