no.inspera.services.pedal.utils
Class ICollections

java.lang.Object
  extended by no.inspera.services.pedal.utils.ICollections

public class ICollections
extends java.lang.Object

Utility class to create generic collections. This is usefull and makes the code somewhat cleaner when the generic types in collection include long class names and/or include nested collections. Example:

Map<Long,Map<String,Map<Long,Long>>> myMap= new HashMap<Long,Map<String,Map<Long,Long>>>();

can be written:

Map<Long,Map<String,Map<Long,Long>>> myMap= ICollections.newMap();

which would be essentially the same, only with cleaner declaration.

Since:
28.08.2007
Version:
$Id: ICollections.java 43983 2008-03-25 00:06:35Z naimdjon $
Author:
Naimdjon Takhirov

Constructor Summary
ICollections()
           
 
Method Summary
static
<E> java.util.Queue<E>
linkedList()
          Constructs a new list.
static
<K,V> java.util.HashMap<K,V>
newHashMap(int initialcapacity)
          Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75).
static
<E> java.util.Set<E>
newHashSet(java.util.Collection<? extends E> c)
          Constructs a new set containing the elements in the specified collection.
static
<K,V> java.util.Hashtable<K,V>
newHashtable()
          Creates a new instance of hashtable.
static
<E> java.util.List<E>
newList()
          Constructs a new list.
static
<K,V> java.util.Map<K,V>
newMap()
          Creates a new instance of HashMap
static
<E> java.util.Set<E>
newSet()
          Constructs a new set.
static
<E> java.util.Vector<E>
newVect()
          Constructs and returns a new vector.
static
<K,V> java.util.SortedMap<K,V>
sortedMap()
           
static
<K,V> java.util.Map<K,V>
synchronizedMap()
          Returns a synchronized (thread-safe) map backed by the specified map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ICollections

public ICollections()
Method Detail

newMap

public static <K,V> java.util.Map<K,V> newMap()
Creates a new instance of HashMap

Returns:
new map.

newHashMap

public static <K,V> java.util.HashMap<K,V> newHashMap(int initialcapacity)
Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75).

Parameters:
initialcapacity - the initial capacity
Returns:
hashmap.

newHashtable

public static <K,V> java.util.Hashtable<K,V> newHashtable()
Creates a new instance of hashtable.

Returns:
hashtable

newHashSet

public static <E> java.util.Set<E> newHashSet(java.util.Collection<? extends E> c)
Constructs a new set containing the elements in the specified collection.

Parameters:
c - the collection whose elements are to be placed into this set.
Returns:
new set

newSet

public static <E> java.util.Set<E> newSet()
Constructs a new set.

Returns:
new set

newList

public static <E> java.util.List<E> newList()
Constructs a new list.

Returns:
new list

linkedList

public static <E> java.util.Queue<E> linkedList()
Constructs a new list.

Returns:
new list

newVect

public static <E> java.util.Vector<E> newVect()
Constructs and returns a new vector.

Returns:
new vector

synchronizedMap

public static <K,V> java.util.Map<K,V> synchronizedMap()
Returns a synchronized (thread-safe) map backed by the specified map. In order to guarantee serial access, it is critical that all access to the backing map is accomplished through the returned map.

Failure to follow this advice may result in non-deterministic behavior.

The returned map will be serializable if the specified map is serializable.

Returns:
a synchronized view of HashMap.

sortedMap

public static <K,V> java.util.SortedMap<K,V> sortedMap()


Copyright © 2008 Naimdjon Takhirov (naimdjon@gmail.com). All Rights Reserved.