Esempio n. 1
0
  public Contact getContactById(Long id) {
    if (id == null) return null;
    for (Contact c : contactList) {
      if (c.getId().equals(id)) {
        return c;
      }
    }

    return null;
  }
Esempio n. 2
0
  public ApiContacts getContacts() {
    ApiContacts apiContacts = new ApiContacts();
    List<ApiContact> apiContactList = new ArrayList<ApiContact>();
    for (Contact c : contactList) {
      ApiContact apiContact = new ApiContact();
      apiContact.setId("" + c.getId());
      apiContact.setName(c.getName());
      apiContact.setEmail(c.getEmail());

      apiContactList.add(apiContact);
    }
    apiContacts.setSize(apiContactList.size());
    apiContacts.setContacts(apiContactList);
    return apiContacts;
  }
Esempio n. 3
0
  public Long saveContact(Contact contact) {
    Long id = new Long(contactList.size() + 1);
    contact.setId(id);
    contactList.add(contact);

    return id;
  }