br.com.arsmachina.controller.impl
Class WriteableControllerImpl<T,K extends Serializable>

java.lang.Object
  extended by br.com.arsmachina.controller.impl.WriteableControllerImpl<T,K>
Type Parameters:
T - the entity class related to this controller.
K - the type of the field that represents the entity class' primary key.
All Implemented Interfaces:
WriteableController<T,K>

public abstract class WriteableControllerImpl<T,K extends Serializable>
extends Object
implements WriteableController<T,K>

Abstract class that implements the WriteableController interface by delegating all method calls to a WriteableDAO passed through its constructor.

Author:
Thiago H. de Paula Figueiredo

Constructor Summary
WriteableControllerImpl(br.com.arsmachina.dao.WriteableDAO<T,K> dao)
          Single constructor of this class.
 
Method Summary
 void delete(K id)
          Invokes dao.delete().
 void delete(T object)
          Invokes dao.delete().
 void evict(T object)
          Invokes dao.evict().
 boolean isPersistent(T object)
          Invokes dao.isPersistent().
 void save(T object)
          Invokes dao.save().
 T saveOrUpdate(T object)
          Invokes save(Object) if the object is persistent and update(Object) otherwise.
 T update(T object)
          Invokes dao.update().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteableControllerImpl

public WriteableControllerImpl(br.com.arsmachina.dao.WriteableDAO<T,K> dao)
Single constructor of this class.

Parameters:
dao - a WriteableDAO. It cannot be null.
Method Detail

isPersistent

public boolean isPersistent(T object)
Invokes dao.isPersistent().

Specified by:
isPersistent in interface WriteableController<T,K extends Serializable>
Parameters:
object -
Returns:
See Also:
WriteableDAO.isPersistent(java.lang.Object)

delete

public void delete(K id)
Invokes dao.delete().

Specified by:
delete in interface WriteableController<T,K extends Serializable>
Parameters:
id -
See Also:
WriteableDAO.delete(java.io.Serializable)

delete

public void delete(T object)
Invokes dao.delete().

Specified by:
delete in interface WriteableController<T,K extends Serializable>
Parameters:
object -
See Also:
WriteableDAO.delete(java.lang.Object)

save

public void save(T object)
Invokes dao.save().

Specified by:
save in interface WriteableController<T,K extends Serializable>
Parameters:
object -
See Also:
WriteableDAO.save(java.lang.Object)

saveOrUpdate

public T saveOrUpdate(T object)
Invokes save(Object) if the object is persistent and update(Object) otherwise. The object is considered persistent if isPersistent(Object) returns true.

Specified by:
saveOrUpdate in interface WriteableController<T,K extends Serializable>
Parameters:
object - a T.
Returns:
a T.

update

public T update(T object)
Invokes dao.update().

Specified by:
update in interface WriteableController<T,K extends Serializable>
Parameters:
object -
Returns:
a T.
See Also:
WriteableDAO.update(java.lang.Object)

evict

public void evict(T object)
Invokes dao.evict().

Specified by:
evict in interface WriteableController<T,K extends Serializable>
Parameters:
object -
See Also:
WriteableDAO.evict(java.lang.Object)


Copyright © 2008-2009 Thiago H. de Paula Figueiredo. All Rights Reserved.