Package org.opendaylight.yangtools.util
Class MapAdaptor
- java.lang.Object
-
- org.opendaylight.yangtools.util.MapAdaptor
-
public final class MapAdaptor extends Object
A simple layer on top of maps, which performs snapshot mediation and optimization of what the underlying implementation is.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COPY_MAX_ITEMS_MAX_PROP
static int
DEFAULT_COPY_MAX_ITEMS
static int
DEFAULT_PERSIST_MIN_ITEMS
static String
PERSIST_MIN_ITEMS_PROP
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MapAdaptor
getDefaultInstance()
Return the default-configured instance.static MapAdaptor
getInstance(boolean useSingleton, int copyMaxItems, int persistMinItems)
<K,V>
Map<K,V>initialSnapshot(int expectedSize)
Creates an initial snapshot.<K,V>
Map<K,V>optimize(Map<K,V> input)
Input will be thrown away, result will be retained for read-only access ortakeSnapshot(Map)
purposes.<K,V>
Map<K,V>takeSnapshot(Map<K,V> input)
Input is treated is supposed to be left unmodified, result must be mutable.
-
-
-
Field Detail
-
DEFAULT_COPY_MAX_ITEMS
public static final int DEFAULT_COPY_MAX_ITEMS
- See Also:
- Constant Field Values
-
COPY_MAX_ITEMS_MAX_PROP
public static final String COPY_MAX_ITEMS_MAX_PROP
- See Also:
- Constant Field Values
-
DEFAULT_PERSIST_MIN_ITEMS
public static final int DEFAULT_PERSIST_MIN_ITEMS
- See Also:
- Constant Field Values
-
PERSIST_MIN_ITEMS_PROP
public static final String PERSIST_MIN_ITEMS_PROP
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefaultInstance
public static MapAdaptor getDefaultInstance()
Return the default-configured instance.- Returns:
- the singleton global instance
-
getInstance
public static MapAdaptor getInstance(boolean useSingleton, int copyMaxItems, int persistMinItems)
-
initialSnapshot
public <K,V> Map<K,V> initialSnapshot(int expectedSize)
Creates an initial snapshot. The backing map is selected according to the expected size.- Parameters:
expectedSize
- Expected map size- Returns:
- An empty mutable map.
-
takeSnapshot
public <K,V> Map<K,V> takeSnapshot(Map<K,V> input)
Input is treated is supposed to be left unmodified, result must be mutable.- Parameters:
input
- input map- Returns:
- An isolated, read-write snapshot of input map
- Throws:
NullPointerException
- if input is null
-
optimize
public <K,V> Map<K,V> optimize(Map<K,V> input)
Input will be thrown away, result will be retained for read-only access ortakeSnapshot(Map)
purposes.- Parameters:
input
- non-optimized (read-write) map- Returns:
- optimized read-only map
- Throws:
NullPointerException
- if input is null
-
-