MAP - is the generic Map-type.public interface MapFactory<MAP extends Map>
maps. It allows to abstract from Map implementations. Map instance can be used for different purposes such as a cache or with different aspects such as a
thread-safe map. If you write a generic component different users of that component may expect different aspects of
your component and therefore the underlying Map. inject an instance of this interface to
override the default, your code will increase usability. MapFactory rather than a Map instance to the constructor?Class to Class<?>) you would break compatibility of the users of your code.
Additionally you may want to express that the Map should be empty and/or NOT shared with others. Anyways the
interface can obviously NOT guarantee this.HashMapFactory.INSTANCE| Modifier and Type | Method and Description |
|---|---|
<K,V> Map<K,V> |
create()
This method creates a new
Map instance. |
<K,V> Map<K,V> |
create(int capacity)
This method creates a new
Map instance with the given capacity. |
MAP |
createGeneric()
This method creates a new instance of the generic
Map type <MAP>. |
MAP |
createGeneric(int capacity)
This method creates a new instance of the generic
Map type <MAP>. |
Class<? extends MAP> |
getMapImplementation()
This method gets the implementation of the
map-interface used by this factory. |
Class<MAP> |
getMapInterface()
This method gets the interface of the
Map managed by this factory. |
Class<MAP> getMapInterface()
Map managed by this factory.Map interface.Class<? extends MAP> getMapImplementation()
map-interface used by this factory.Map implementation.<K,V> Map<K,V> create()
Map instance. Map can NOT be bound to the generic type <MAP> because of limitations in Java's generic type
system. You need to work on the actual sub-interface (e.g. SortedMapFactory) to get a more specific result
type.K - the type of keys maintained by the map.V - the type of mapped values.<K,V> Map<K,V> create(int capacity)
Map instance with the given capacity. For a regular map this will be the
initial capacity while a cache may never grow beyond this capacity limit and if reached force out entries last
recently of frequently used.K - the type of keys maintained by the map.V - the type of mapped values.capacity - is the capacity of the map to create.MAP createGeneric()
Map type <MAP>.Map instance.Copyright © 2001–2016 mmm-Team. All rights reserved.