uk.org.ury.backend.database
Class DatabaseItem<E,T>

java.lang.Object
  extended by uk.org.ury.backend.database.DatabaseItem<E,T>
Direct Known Subclasses:
LibraryItem, ShowItem

public abstract class DatabaseItem<E,T>
extends java.lang.Object

An abstract class presenting a template for objects serving as a data structure for collections of properties retrieved from a SQL database.

Author:
Matt Windsor

Constructor Summary
DatabaseItem(java.util.Map<E,T> properties)
          Construct a new item from an existing list of properties.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.String> asResponse()
          Retrieve a map of string representations of the properties.
 T get(E property)
          Query this item for a property.
 boolean has(E property)
          Check whether a property has been set in the item.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseItem

public DatabaseItem(java.util.Map<E,T> properties)
Construct a new item from an existing list of properties.

Parameters:
properties - The map of properties that the new item will inherit.
Method Detail

has

public boolean has(E property)
Check whether a property has been set in the item.

Returns:
true if the property has been set; false otherwise.

get

public T get(E property)
      throws MissingPropertyException
Query this item for a property.

Parameters:
property - The property to query.
Returns:
The property, if it exists.
Throws:
MissingPropertyException - if the property does not exist.

asResponse

public java.util.Map<java.lang.String,java.lang.String> asResponse()
Retrieve a map of string representations of the properties. This relies on E and T having meaningful toString methods.

Returns:
a list of lines representing the response.