GNDMS 0.6.0
RESTful verison of GNDMS
|
Public Member Functions | |
K | create (D descriptor) |
Creates a fresh instance of M matching descriptor. | |
void | add (M model, K key) |
Addes a model to the dao. | |
M | get (K key) throws NoSuchElementException |
Used to retrive an model object form the dao. | |
void | deleteByKey (K key) |
Deletes a model matching the given key. | |
void | delete (M model) |
This is expensive, so don't lose your key. | |
Protected Member Functions | |
M | cacheGet (K key) |
Map< K, M > | getModels () |
void | setModels (Cache< K, M > models) |
Private Attributes | |
Cache< K, M > | models |
Date: 23.12.2010, Time: 12:32:07
Transient dao uses a hashmap to store key model associations.
void de.zib.gndms.model.common.repository.TransientDao< K, M, D >.add | ( | M | model, |
K | key | ||
) |
Addes a model to the dao.
model | The model to add, with the key to use. |
Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.
{ models.asMap().put( key, model ); }
K de.zib.gndms.model.common.repository.TransientDao< K, M, D >.create | ( | D | descriptor | ) |
Creates a fresh instance of M matching descriptor.
This can be used fine grained construction, i.e. if M is a base class.
descriptor | The descriptor of the object, i.e. class. |
Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.
{ return create( ); }
void de.zib.gndms.model.common.repository.TransientDao< K, M, D >.delete | ( | M | model | ) |
This is expensive, so don't lose your key.
model | The model to delete. |
Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.
{ for ( K key: models.asMap().keySet() ) { try { if( models.get( key ).equals( model ) ) { deleteByKey( key ); return; } } catch ( ExecutionException e ) { // intentionally } } }
void de.zib.gndms.model.common.repository.TransientDao< K, M, D >.deleteByKey | ( | K | key | ) |
Deletes a model matching the given key.
key | The key. |
NOTE: Stupid type erasure.
Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.
{ models.invalidate( key ); }
M de.zib.gndms.model.common.repository.TransientDao< K, M, D >.get | ( | K | key | ) | throws NoSuchElementException |
Used to retrive an model object form the dao.
key | The key of the object. |
Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.
{ if( models.asMap().containsKey( key ) ) try { return models.get( key ); } catch ( ExecutionException e ) { throw new NoSuchElementException( key.toString() ); } throw new NoSuchElementException( key.toString() ); }