@Override public void setOption(User user, String key, String value) { // TODO better design? for (UserOption currentOption : user.getOptions()) { if (currentOption.getKey().equals(key)) { if (!currentOption.getValue().equals(value)) { currentOption.setValue(value); userDao.update(user); return; } } } user.getOptions().add(new UserOption(key, value)); userDao.update(user); return; }
@Override public User resolveUser(String recipient) { if (resolvedUserIds.containsKey(recipient)) { return resolvedUserIds.get(recipient); } // Resolve by email User user = userDao.getByEmail(recipient); if (user != null) { resolvedUserIds.put(recipient, user); return user; } user = userDao.getByUsername(recipient); if (user != null) { resolvedUserIds.put(recipient, user); return user; } // TODO implement later? /* // Resolve by full name user = userDao.getUserByFullName(recipient); if (user != null) { resolvedUserIds.put(recipient, user); return user; } recipient = reverseFullName(recipient); // Resolve by full name reversed user = userDao.getUserByFullName(recipient); if (user != null) { resolvedUserIds.put(recipient, user); return user; } */ return null; }