public void createContact(String login, String firstName, String lastName, LocalDate birthDate) { // contact = new Contact(login, firstName, lastName, birthDate); if (contactDao.getContactMap().containsKey(login)) { System.out.println("This login isn't unique! Enter unique login"); } else { contact.setLogin(login); } contact.setFirstName(firstName); contact.setLastName(lastName); contact.setBirthDate(birthDate); contactDao.addContact(contact); }
public Set<Contact> getFriendList(Contact contact) { Set<Contact> friendSet = new HashSet<>(); Map<String, Friends> friendsMap = contactDao.getFriendshipMap(); ArrayList<Friends> friendsList = (ArrayList<Friends>) friendsMap.values(); for (Friends friends : friendsList) { if (friends.getFriendFrom().equals(contact)) { friendSet.add(friends.getFriendTo()); } if (friends.getFriendTo().equals(contact)) { friendSet.add(friends.getFriendFrom()); } if (!friends.getFriendFrom().equals(contact) && !friends.getFriendTo().equals(contact)) { System.out.println("I'm alone(Teach-In)"); } } return friendSet; }
public void addFriendship(Contact contactFrom, Contact contactTo) { contactDao.addFriendship(contactFrom, contactTo); }