Ejemplo 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;
  }
Ejemplo 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;
  }