org.glassfish.jersey.examples.beanvalidation.webapp.service
Class StorageService

java.lang.Object
  extended by org.glassfish.jersey.examples.beanvalidation.webapp.service.StorageService

public class StorageService
extends Object

Simple storage of contacts.

Author:
Michal Gajdos (michal.gajdos at oracle.com)

Constructor Summary
StorageService()
           
 
Method Summary
static ContactCard addContact(ContactCard contact)
          Adds a contact into the storage.
static List<ContactCard> clear()
          Removes all contacts from the storage.
static List<ContactCard> findByEmail(String emailPart)
          Finds contacts whose email contains emailPart as a substring.
static List<ContactCard> findByName(String namePart)
          Finds contacts whose name contains namePart as a substring.
static List<ContactCard> findByPhone(String phonePart)
          Finds contacts whose phone contains phonePart as a substring.
static ContactCard get(Long id)
          Retrieves contact with given id.
static ContactCard remove(Long id)
          Removes contact with given id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StorageService

public StorageService()
Method Detail

addContact

public static ContactCard addContact(ContactCard contact)
Adds a contact into the storage. If a contact with given data already exist null value is returned.

Parameters:
contact - contact to be added.
Returns:
contact with pre-filled id field, null if the contact already exist in the storage.

clear

public static List<ContactCard> clear()
Removes all contacts from the storage.

Returns:
list of all removed contacts.

remove

public static ContactCard remove(Long id)
Removes contact with given id.

Parameters:
id - id of the contact to be removed.
Returns:
removed contact or null if the contact is not present in the storage.

get

public static ContactCard get(Long id)
Retrieves contact with given id.

Parameters:
id - id of the contact to be retrieved.
Returns:
contact or null if the contact is not present in the storage.

findByEmail

public static List<ContactCard> findByEmail(String emailPart)
Finds contacts whose email contains emailPart as a substring.

Parameters:
emailPart - search phrase.
Returns:
list of matched contacts or an empty list.

findByName

public static List<ContactCard> findByName(String namePart)
Finds contacts whose name contains namePart as a substring.

Parameters:
namePart - search phrase.
Returns:
list of matched contacts or an empty list.

findByPhone

public static List<ContactCard> findByPhone(String phonePart)
Finds contacts whose phone contains phonePart as a substring.

Parameters:
phonePart - search phrase.
Returns:
list of matched contacts or an empty list.


Copyright © 2007-2013 Oracle Corporation. All Rights Reserved. Use is subject to license terms.