org.expasy.jpl.commons.collection
Class PoolImpl<T extends Cachable>

java.lang.Object
  extended by org.expasy.jpl.commons.collection.PoolImpl<T>
Type Parameters:
T - the Cachable objects.
All Implemented Interfaces:
Pool<T>, Register<T>

public final class PoolImpl<T extends Cachable>
extends Object
implements Pool<T>

This pool stores unique and immutable objects.

Version:
1.0
Author:
nikitin

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.expasy.jpl.commons.collection.Pool
Pool.KeyAlreadyExistException, Pool.ObjectAlreadyExistException
 
Method Summary
 void clear()
          Clear the register.
 Set<String> getKeys()
          Get keys of all stored objects.
 Set<T> getValues()
          Get values of all stored objects.
 boolean isRegistered(String id)
          
 boolean isRegistered(T o)
          Return true if object exists in pool.
 T lookup(String id)
          
static
<T extends Cachable>
PoolImpl<T>
newInstance()
           
 void register(T o)
           
 int size()
          
 String toString()
           
 T unregister(String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

newInstance

public static <T extends Cachable> PoolImpl<T> newInstance()

register

public void register(T o)
Specified by:
register in interface Register<T extends Cachable>

unregister

public T unregister(String id)
Specified by:
unregister in interface Register<T extends Cachable>

isRegistered

public final boolean isRegistered(String id)

Specified by:
isRegistered in interface Register<T extends Cachable>

isRegistered

public final boolean isRegistered(T o)
Return true if object exists in pool.

Specified by:
isRegistered in interface Pool<T extends Cachable>
Parameters:
o - the object.
Returns:
true if exists.

lookup

public T lookup(String id)

Specified by:
lookup in interface Register<T extends Cachable>

getKeys

public Set<String> getKeys()
Get keys of all stored objects.

Specified by:
getKeys in interface Pool<T extends Cachable>
Returns:
the key set.

getValues

public Set<T> getValues()
Get values of all stored objects.

Specified by:
getValues in interface Pool<T extends Cachable>
Returns:
the value set.

size

public int size()

Specified by:
size in interface Register<T extends Cachable>
Returns:
the number of registered objects.

clear

public void clear()
Clear the register.

Specified by:
clear in interface Register<T extends Cachable>

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.