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 java.lang.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 java.util.List<ContactCard> clear()
          Removes all contacts from the storage.
static java.util.List<ContactCard> findByEmail(java.lang.String emailPart)
          Finds contacts whose email contains emailPart as a substring.
static java.util.List<ContactCard> findByName(java.lang.String namePart)
          Finds contacts whose name contains namePart as a substring.
static java.util.List<ContactCard> findByPhone(java.lang.String phonePart)
          Finds contacts whose phone contains phonePart as a substring.
static ContactCard get(java.lang.Long id)
          Retrieves contact with given id.
static ContactCard remove(java.lang.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 java.util.List<ContactCard> clear()
Removes all contacts from the storage.

Returns:
list of all removed contacts.

remove

public static ContactCard remove(java.lang.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(java.lang.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 java.util.List<ContactCard> findByEmail(java.lang.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 java.util.List<ContactCard> findByName(java.lang.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 java.util.List<ContactCard> findByPhone(java.lang.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.