|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.map.MapUtils
public class MapUtils
Helper class for Map operations.
| Nested Class Summary | |
|---|---|
static interface |
MapUtils.MapElementMergeOperation<K,V>
A MapUtils.MapElementMergeOperation defines a MapUtils.MapElementMergeOperation.merge(Object, Object, Map) operation to merge Map elements into
a merged Map instance. |
static interface |
MapUtils.MapEntryToElementConverter<TO,K,V>
Converted to transform a given Map.Entry of a Map to a single List element |
| Constructor Summary | |
|---|---|
MapUtils()
|
|
| Method Summary | ||
|---|---|---|
static
|
adapter(Map<KEY_FROM,VALUE_FROM> sourceMap,
ElementBidirectionalConverter<KEY_FROM,KEY_TO> elementBidirectionalConverterKey,
ElementBidirectionalConverter<VALUE_FROM,VALUE_TO> elementBidirectionalConverterValue)
Returns a MapToMapAdapter for the given source Map |
|
static
|
adapter(SortedMap<KEY,VALUE_FROM> sourceMap,
ElementBidirectionalConverter<VALUE_FROM,VALUE_TO> elementBidirectionalConverterValue)
Returns a SortedMapToSortedMapAdapter for the given source SortedMap |
|
static
|
aggregatedMap(Iterable<? extends Map<K,V>> mapIterable)
Returns an AggregatedMap for the given Maps |
|
static MapBuilder |
builder()
Returns a new MapBuilder instance. |
|
static
|
composite(List<Map<K,V>> mapList)
Returns a new MapComposite instance for the given Maps |
|
static
|
composite(Map<K,V>... maps)
Returns a new MapComposite instance for the given Maps |
|
static
|
convertMap(Map<? extends KeyFrom,? extends ValueFrom> map,
ElementConverter<KeyFrom,KeyTo> keyElementConverter,
ElementConverter<ValueFrom,ValueTo> valueElementConverter)
Returns a new Map instance with converted keys and values using the given ElementConverters |
|
static
|
convertMap(Map<? extends KeyFrom,? extends ValueFrom> map,
ElementConverter<Map.Entry<KeyFrom,ValueFrom>,Map.Entry<KeyTo,ValueTo>> entryElementConverter)
Similar to convertMap(Map, ElementConverter, ElementConverter) using a single ElementConverter for an
Map.Entry |
|
static
|
convertMapKey(Map<? extends KeyFrom,? extends Value> map,
ElementConverter<KeyFrom,KeyTo> keyElementConverter)
Returns a new Map instance with converted keys using the given ElementConverter |
|
static
|
convertMapValue(Map<? extends Key,? extends ValueFrom> map,
ElementConverter<ValueFrom,ValueTo> valueElementConverter)
Returns a new Map instance with all values converted using the given ElementConverter |
|
static
|
defaultValueMap(Map<K,V> map,
FactoryParameterized<V,K> valueFactory)
Returns a Map which always returns a value prodcued by the given factory if the value would have be null |
|
static
|
defaultValueMap(Map<K,V> map,
V defaultValue)
Similar to defaultValueMap(Map, FactoryParameterized) |
|
static
|
delta(Map<K,V> mapFirst,
Map<K,V> mapSecond)
Returns a new MapDelta for the given two Map instances |
|
static
|
entryAt(Map<K,V> map,
int indexPosition)
Returns the Map.Entry at the given index position of the given Map. |
|
static
|
filteredMap(Map<K,V> map,
ElementFilter<K> keyElementFilter)
Returns a new filtered Map instance. |
|
static
|
filteredMap(Map<K,V> map,
Iterable<K> filterKeyIterable)
Filters a given Map by its keys. |
|
static
|
filteredMapExcludingNullValues(Map<K,V> map)
Filters a given Map by values which are null. |
|
static
|
filteredValues(Map<K,V> map,
Class<V> valueType,
K... keys)
|
|
static
|
firstEntry(Map<K,V> map)
Returns the first Map.Entry of a given Map or null if the Map reference is null or the Map is
empty |
|
static
|
getValueByRegex(Map<String,? extends E> map,
String regex)
Returns the value of the first key within a Map which matches a given regular expression. |
|
static
|
initializedCounterMap()
Returns a Map instance which returns for Map.get(Object) always an AtomicInteger instance. |
|
static
|
initializedEnumMap(Class<K> enumType,
Factory<V> factory)
Returns an EnumMap filled with all available values of the given Enum type as keys and the result of the
Factory as value for each Enum key. |
|
static
|
initializedMap(Factory<V> valueFactory)
Similar to initializedMap(Map, Factory) using a new LinkedHashMap instance |
|
static
|
initializedMap(FactoryParameterized<V,K> valueFactory)
Similar to initializedMap(Map, FactoryParameterized) using a new LinkedHashMap instance |
|
static
|
initializedMap(Map<K,V> map,
Factory<V> valueFactory)
Returns a MapDecorator which ensures that all Map.get(Object) invocations with a valid key type will return a
value. |
|
static
|
initializedMap(Map<K,V> map,
FactoryParameterized<V,K> valueFactory)
Returns a MapDecorator which ensures that all Map.get(Object) invocations with a valid key type will return a
value. |
|
static
|
initializedSortedMap(SortedMap<K,V> sortedMap,
Factory<V> valueFactory)
Similar to initializedMap(Map, Factory) but for any SortedMap instance |
|
static
|
initializedValueListMap()
Short form of initializedMap(Factory) using an ArrayListFactory |
|
static
|
initializedValueListMap(Map<K,List<V>> map)
Short form of initializedMap(Factory) using an ArrayListFactory |
|
static
|
initializedValueSetMap()
Short form of initializedMap(Factory) using an LinkedHashSetFactory |
|
static
|
initializedValueSetMap(Map<K,Set<V>> map)
Short form of initializedMap(Factory) using an LinkedHashSetFactory |
|
static
|
initializeMap(Map<K,V> map,
Iterable<K> keyIterable,
Factory<V> valueFactory)
Similar to initializeMap(Map, Iterable, Factory, boolean) but does not overwrite values of already existing keys. |
|
static
|
initializeMap(Map<K,V> map,
Iterable<K> keyIterable,
Factory<V> valueFactory,
boolean overwriteValuesOfExistingKeys)
Initializes the given Map for all keys from the key Iterable with values created by the value
Factory.newInstance() method. |
|
static
|
innerJoinMapByKey(Map<K,VA> mapA,
Map<K,VB> mapB)
Returns a Map with the matching keys and the respective value instances within a of Tuple2 wrapper, which has
always the value of the first map and the value of the second map. |
|
static
|
invert(Map<? extends K,? extends V> map)
Returns the inverted Map for the given one. |
|
static
|
invertedBidirectionalMap(Map<? extends K,? extends V> map)
Returns the inverted Map for the given one. |
|
static boolean |
isMapType(Class<?> type)
Returns true if the given type is assignable to the Map interface |
|
static boolean |
isSortedMapType(Class<?> type)
Returns true if the given type is assignable to the SortedMap interface |
|
static MapJoiner |
joiner()
Returns a new MapJoiner instance |
|
static
|
lastEntry(Map<K,V> map)
Returns the last Map.Entry of the given Map. |
|
static
|
locked(Map<K,V> map,
Lock lock)
Returns a view of the given Map using the given Lock to synchronize all of its methods |
|
static
|
lockedByReentrantLock(Map<K,V> map)
Returns a view of the given Map using a new ReentrantLock instance to synchronize all of its methods |
|
static
|
mergeAll(Collection<Map<? extends K,? extends V>> mapCollection,
MapUtils.MapElementMergeOperation<K,V> mapElementMergeOperation)
Merges all given Map instances into a single LinkedHashMap using the given MapUtils.MapElementMergeOperation. |
|
static
|
mergeAll(Collection<Map<K,V>> mapCollection)
Merges all given Map instances into a single LinkedHashMap. |
|
static
|
mergeAll(Map<K,V>... maps)
Merges all given Map instances into a single LinkedHashMap. |
|
static
|
mergeAll(MapUtils.MapElementMergeOperation<K,V> mapElementMergeOperation,
Map<? extends K,? extends V>... maps)
Merges all given Map instances into a single LinkedHashMap using the given MapUtils.MapElementMergeOperation. |
|
static
|
mergeAllValuesIntoList(Collection<Map<K,V>> mapCollection)
Merges multiple Map instances whereby multiple values for the same key are merged into a List |
|
static
|
mergeAllValuesIntoList(Map<K,V>... maps)
Similar to mergeAllValuesIntoList(Collection) |
|
static
|
mergeAllValuesIntoSet(Collection<Map<K,V>> mapCollection)
Merges multiple Map instances whereby multiple values for the same key are merged into a Set |
|
static
|
mergeAllValuesIntoSet(Map<K,V>... maps)
Similar to mergeAllValuesIntoSet(Collection) |
|
static Map<String,String> |
parseString(String content)
Similar to parseString(String, String, String) |
|
static Map<String,String> |
parseString(String content,
String entityDelimiterRegEx,
String keyValueDelimiterRegEx)
Parses a given text into a LinkedHashMap instance. |
|
static void |
printMapHierarchical(PrintStream printStream,
Map map)
Prints out a given Map using String.valueOf(Object) and all submaps indented to a new column. |
|
static
|
putIfAbsent(Map<K,V> map,
K key,
Factory<V> valueFactory)
Puts the given key and value into the given Map only if there is no equal key already contained within the
Map. |
|
static
|
putIfAbsent(Map<K,V> map,
K key,
V value)
Puts the given key and value into the given Map only if there is no equal key already contained within the
Map. |
|
static int |
size(Map<?,?> map)
Returns the size of the given Map or 0 if the given Map reference is null. |
|
static
|
toList(Map<K,V> map,
MapUtils.MapEntryToElementConverter<TO,K,V> mapEntryToElementConverter)
Transforms a given Map to a List using the given MapUtils.MapEntryToElementConverter to create single elements
for the List based on the Map.Entrys of the given Map |
|
static
|
toString(Map<K,V> map)
Returns a String representation for a Map |
|
static
|
toStringUsingHierarchy(Map<K,V> map)
Similar to printMapHierarchical(PrintStream, Map) but returning a String value |
|
static
|
valueOf(Iterable<E> iterable,
ElementConverterElementToMapEntry<E,K,V> elementToMapEntryTransformer)
Returns a new Map instance for the given Iterable using the ElementConverterElementToMapEntry
instance to convert every element to an Map.Entry |
|
static
|
valueOf(KeyExtractor<? extends K,V> keyExtractor,
Iterable<? extends V> iterable)
Returns a new Map instance for the given Iterable using the given KeyExtractor to extract every key
one by one from the Iterable |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MapUtils()
| Method Detail |
|---|
public static <K,V> Map<K,V> mergeAll(MapUtils.MapElementMergeOperation<K,V> mapElementMergeOperation,
Map<? extends K,? extends V>... maps)
Map instances into a single LinkedHashMap using the given MapUtils.MapElementMergeOperation.
K - V - mapElementMergeOperation - maps -
mergeAll(Map...),
mergeAll(Collection, MapElementMergeOperation)
public static <K,V> Map<K,V> mergeAll(Collection<Map<? extends K,? extends V>> mapCollection,
MapUtils.MapElementMergeOperation<K,V> mapElementMergeOperation)
Map instances into a single LinkedHashMap using the given MapUtils.MapElementMergeOperation.
K - V - mapCollection - mapElementMergeOperation -
mergeAll(Map...)public static <K,V> Map<K,V> mergeAll(Collection<Map<K,V>> mapCollection)
Map instances into a single LinkedHashMap.
K - V - mapCollection -
mergeAll(Map...)public static <K,V> Map<K,V> mergeAll(Map<K,V>... maps)
Map instances into a single LinkedHashMap.
K - V - maps -
mergeAll(Collection),
mergeAll(Collection, MapElementMergeOperation)public static <K,V> Map<K,List<V>> mergeAllValuesIntoList(Map<K,V>... maps)
mergeAllValuesIntoList(Collection)
maps -
public static <K,V> Map<K,List<V>> mergeAllValuesIntoList(Collection<Map<K,V>> mapCollection)
Map instances whereby multiple values for the same key are merged into a List
mapCollection -
public static <K,V> Map<K,Set<V>> mergeAllValuesIntoSet(Map<K,V>... maps)
mergeAllValuesIntoSet(Collection)
maps -
public static <K,V> Map<K,Set<V>> mergeAllValuesIntoSet(Collection<Map<K,V>> mapCollection)
Map instances whereby multiple values for the same key are merged into a Set
mapCollection -
public static <K,VA,VB> Map<K,Tuple2<VA,VB>> innerJoinMapByKey(Map<K,VA> mapA,
Map<K,VB> mapB)
Map with the matching keys and the respective value instances within a of Tuple2 wrapper, which has
always the value of the first map and the value of the second map. Only the keys which are contained in both Maps
will be returned.
K - VA - VB - mapA - mapB -
public static MapJoiner joiner()
MapJoiner instance
public static <KeyFrom,KeyTo,Value> Map<KeyTo,Value> convertMapKey(Map<? extends KeyFrom,? extends Value> map,
ElementConverter<KeyFrom,KeyTo> keyElementConverter)
Map instance with converted keys using the given ElementConverter
KeyFrom - KeyTo - Value - map - keyElementConverter -
MapconvertMap(Map, ElementConverter, ElementConverter),
convertMapValue(Map, ElementConverter)
public static <Key,ValueFrom,ValueTo> Map<Key,ValueTo> convertMapValue(Map<? extends Key,? extends ValueFrom> map,
ElementConverter<ValueFrom,ValueTo> valueElementConverter)
Map instance with all values converted using the given ElementConverter
Key - ValueFrom - ValueTo - map - valueElementConverter -
MapconvertMapKey(Map, ElementConverter),
convertMap(Map, ElementConverter, ElementConverter)
public static <KeyFrom,KeyTo,ValueFrom,ValueTo> Map<KeyTo,ValueTo> convertMap(Map<? extends KeyFrom,? extends ValueFrom> map,
ElementConverter<KeyFrom,KeyTo> keyElementConverter,
ElementConverter<ValueFrom,ValueTo> valueElementConverter)
Map instance with converted keys and values using the given ElementConverters
map - keyElementConverter - valueElementConverter -
MapconvertMapKey(Map, ElementConverter),
convertMapValue(Map, ElementConverter),
ElementConverter
public static <KeyFrom,KeyTo,ValueFrom,ValueTo> Map<KeyTo,ValueTo> convertMap(Map<? extends KeyFrom,? extends ValueFrom> map,
ElementConverter<Map.Entry<KeyFrom,ValueFrom>,Map.Entry<KeyTo,ValueTo>> entryElementConverter)
convertMap(Map, ElementConverter, ElementConverter) using a single ElementConverter for an
Map.Entry
map - MapentryElementConverter - ElementConverter
Map instancepublic static <K,V> String toStringUsingHierarchy(Map<K,V> map)
printMapHierarchical(PrintStream, Map) but returning a String value
map -
public static <K,V> String toString(Map<K,V> map)
String representation for a Map
map -
public static <TO,K,V> List<TO> toList(Map<K,V> map,
MapUtils.MapEntryToElementConverter<TO,K,V> mapEntryToElementConverter)
Map to a List using the given MapUtils.MapEntryToElementConverter to create single elements
for the List based on the Map.Entrys of the given Map
map - mapEntryToElementConverter -
List
public static <K,V> Map<K,V> filteredMap(Map<K,V> map,
ElementFilter<K> keyElementFilter)
Map instance. All keys of the given Map are filtered using the given
ElementFilter
map - keyElementFilter -
filteredMap(Map, Iterable)
public static <K,V> Map<K,V> filteredMap(Map<K,V> map,
Iterable<K> filterKeyIterable)
Map by its keys. Only keys which are contained within the given key Iterable will be
returned.
map - filterKeyIterable -
LinkedHashMap instancefilteredMap(Map, ElementFilter)public static <K,V> Map<K,V> filteredMapExcludingNullValues(Map<K,V> map)
Map by values which are null. Only keys which have a value not null will be retained.
map -
LinkedHashMap instance
public static void printMapHierarchical(PrintStream printStream,
Map map)
Map using String.valueOf(Object) and all submaps indented to a new column.-+ |-- valueDouble=1.234 |-+ testClassCopy | |-- valueDouble=5.678 | |-- testClassCopy=null | |-- privateField=privateValue0.16433438667207334 | |-+ future | | |-- countDownLatch=java.util.concurrent.CountDownLatch@1f4384c2[Count = 1] | | |-- shouldCancel=false | | |-- isCancelled=false | | |-- value=null | | |-- clazz=org.omnaest.utils.structure.element.FutureSimple
printStream - map -
public static <K,V> Map<K,V> locked(Map<K,V> map,
Lock lock)
Map using the given Lock to synchronize all of its methods
map - lock -
lockedByReentrantLock(Map)public static <K,V> Map<K,V> lockedByReentrantLock(Map<K,V> map)
Map using a new ReentrantLock instance to synchronize all of its methods
map -
locked(Map, Lock)public static <K,V> Map<V,K> invertedBidirectionalMap(Map<? extends K,? extends V> map)
Map for the given one.Map has to be bidirectional, which means that the key value pairs inverted into value to key pairs
have unique values, too.Map reference is null, null is returned.Maps use invert(Map) instead. Map has some non unique values the first occurring value wins and all further values are dropped.
map -
LinkedHashMappublic static <K,V> Map<V,Set<K>> invert(Map<? extends K,? extends V> map)
Map for the given one. If the given Map reference is null, null is returned.Map can be mapped to the same value, the inverted Map will contain a
Set of original key values per original value. Maps consider using invertedBidirectionalMap(Map)
map -
LinkedHashMap and LinkedHashSet
public static <K extends Enum<K>,V> EnumMap<K,V> initializedEnumMap(Class<K> enumType,
Factory<V> factory)
EnumMap filled with all available values of the given Enum type as keys and the result of the
Factory as value for each Enum key.
enumType - factory -
EnumMap
public static <K,V> void initializeMap(Map<K,V> map,
Iterable<K> keyIterable,
Factory<V> valueFactory)
initializeMap(Map, Iterable, Factory, boolean) but does not overwrite values of already existing keys.
map - keyIterable - valueFactory -
public static <K,V> void initializeMap(Map<K,V> map,
Iterable<K> keyIterable,
Factory<V> valueFactory,
boolean overwriteValuesOfExistingKeys)
Map for all keys from the key Iterable with values created by the value
Factory.newInstance() method. If the overwrite values of existing keys flag is set to true, any value of an already
existing key is overwritten.
map - keyIterable - valueFactory - overwriteValuesOfExistingKeys - initializedMap(Map, Factory)public static <K,V> Map<K,V> initializedMap(Factory<V> valueFactory)
initializedMap(Map, Factory) using a new LinkedHashMap instance
valueFactory -
public static <K,V> Map<K,V> initializedMap(FactoryParameterized<V,K> valueFactory)
initializedMap(Map, FactoryParameterized) using a new LinkedHashMap instance
valueFactory -
public static <K,V> Map<K,V> initializedMap(Map<K,V> map,
Factory<V> valueFactory)
MapDecorator which ensures that all Map.get(Object) invocations with a valid key type will return a
value. If the underlying Map would return a null value the value Factory.newInstance() is invoked and the new
value is stored within the Map.Map contains a Collection as value and the Collection
should always be present.Map.containsKey(Object) will still return false for any non existing key.
map - valueFactory -
Map decoratorinitializeMap(Map, Iterable, Factory)public static <K,V> Map<K,List<V>> initializedValueListMap()
initializedMap(Factory) using an ArrayListFactory
public static <K,V> Map<K,List<V>> initializedValueListMap(Map<K,List<V>> map)
initializedMap(Factory) using an ArrayListFactory
map - underlying Map
public static <K,V> Map<K,Set<V>> initializedValueSetMap()
initializedMap(Factory) using an LinkedHashSetFactory
public static <K,V> Map<K,Set<V>> initializedValueSetMap(Map<K,Set<V>> map)
initializedMap(Factory) using an LinkedHashSetFactory
map - underlying Map
public static <K,V> Map<K,V> initializedMap(Map<K,V> map,
FactoryParameterized<V,K> valueFactory)
MapDecorator which ensures that all Map.get(Object) invocations with a valid key type will return a
value. If the underlying Map would return a null value the value FactoryParameterized.newInstance(Object)
with the key as argument is invoked and the new value is stored within the Map.Map contains a Collection as value and the Collection
should always be present.Map.containsKey(Object) will still return false for any non existing key.
map - valueFactory - FactoryParameterized
Map decoratorinitializeMap(Map, Iterable, Factory),
initializedMap(Map, Factory)
public static <K,V> Map<K,V> defaultValueMap(Map<K,V> map,
V defaultValue)
defaultValueMap(Map, FactoryParameterized)
map - defaultValue -
initializedMap(FactoryParameterized)
public static <K,V> Map<K,V> defaultValueMap(Map<K,V> map,
FactoryParameterized<V,K> valueFactory)
Map which always returns a value prodcued by the given factory if the value would have be null
map - valueFactory -
initializedMap(Map, FactoryParameterized)
public static <K,V> SortedMap<K,V> initializedSortedMap(SortedMap<K,V> sortedMap,
Factory<V> valueFactory)
initializedMap(Map, Factory) but for any SortedMap instance
sortedMap - valueFactory -
SortedMap decorator
public static <E> E getValueByRegex(Map<String,? extends E> map,
String regex)
Map which matches a given regular expression.MapUtils.getValueByRegex( null, anyRegex ) = null MapUtils.getValueByRegex( map, null ) = null MapUtils.getValueByRegex( map, regex ) = value for first key matching the regex MapUtils.getValueByRegex( map, ".*" ) = first value of the map forLinkedHashMap, random value forHashMap
// final Map<String, String> map = new LinkedHashMap<String, String>(); map.put( "key1", "value1" ); map.put( "key2", "value2" ); map.put( "thisKey", "value3" ); // String regex = "this.*"; String value = MapUtils.getValueByRegex( map, regex ); // assertEquals( "value3", value );
map - regex -
public static <K,V> Map.Entry<K,V> firstEntry(Map<K,V> map)
Map.Entry of a given Map or null if the Map reference is null or the Map is
empty
map -
lastEntry(Map),
entryAt(Map, int)public static <K,V> Map.Entry<K,V> lastEntry(Map<K,V> map)
Map.Entry of the given Map. If the given Map reference is null or the Map is
empty, null will be returned.
map -
firstEntry(Map),
entryAt(Map, int)
public static <K,V> Map.Entry<K,V> entryAt(Map<K,V> map,
int indexPosition)
Map.Entry at the given index position of the given Map. If null is given as Map null will be
returned. If the index position is invalid null is returned, too.
map - indexPosition -
firstEntry(Map),
lastEntry(Map)
public static <K,V> Map<K,V> valueOf(KeyExtractor<? extends K,V> keyExtractor,
Iterable<? extends V> iterable)
Map instance for the given Iterable using the given KeyExtractor to extract every key
one by one from the Iterable
keyExtractor - KeyExtractoriterable - Iterable
Map
public static <K,V,E> Map<K,V> valueOf(Iterable<E> iterable,
ElementConverterElementToMapEntry<E,K,V> elementToMapEntryTransformer)
Map instance for the given Iterable using the ElementConverterElementToMapEntry
instance to convert every element to an Map.Entry
iterable - elementToMapEntryTransformer -
public static <K,V> Map<K,V> composite(Map<K,V>... maps)
MapComposite instance for the given Maps
maps -
public static <K,V> Map<K,V> composite(List<Map<K,V>> mapList)
MapComposite instance for the given Maps
mapList -
public static <KEY_FROM,VALUE_FROM,KEY_TO,VALUE_TO> Map<KEY_TO,VALUE_TO> adapter(Map<KEY_FROM,VALUE_FROM> sourceMap,
ElementBidirectionalConverter<KEY_FROM,KEY_TO> elementBidirectionalConverterKey,
ElementBidirectionalConverter<VALUE_FROM,VALUE_TO> elementBidirectionalConverterValue)
MapToMapAdapter for the given source Map
sourceMap - MapelementBidirectionalConverterKey - ElementBidirectionalConverterelementBidirectionalConverterValue - ElementBidirectionalConverter
MapToMapAdapter instance
public static <KEY,VALUE_FROM,VALUE_TO> SortedMap<KEY,VALUE_TO> adapter(SortedMap<KEY,VALUE_FROM> sourceMap,
ElementBidirectionalConverter<VALUE_FROM,VALUE_TO> elementBidirectionalConverterValue)
SortedMapToSortedMapAdapter for the given source SortedMap
sourceMap - SortedMapelementBidirectionalConverterValue - ElementBidirectionalConverter
SortedMapToSortedMapAdapter instancepublic static Map<String,String> parseString(String content)
parseString(String, String, String)
content -
public static Map<String,String> parseString(String content,
String entityDelimiterRegEx,
String keyValueDelimiterRegEx)
LinkedHashMap instance. key1=value1;key2=value2would be parsed into a
Map with the keys "key1" and "key2" and "key1" would have the value "value1" and similar for
"key2".
content - entityDelimiterRegEx - defaults to ";" or "|"keyValueDelimiterRegEx - defaults to "=" or ":"
public static boolean isMapType(Class<?> type)
Map interface
type -
public static boolean isSortedMapType(Class<?> type)
SortedMap interface
type -
public static MapBuilder builder()
MapBuilder instance.
Map<String, Long> map = MapUtils.builder()
.put( "key1", 1l )
.put( "key2", 2l )
.put( "key3", 3l )
.put( "key4", 4l )
.buildAs()
.linkedHashMap();
Map<String, Object> map = MapUtils.builder()
.<String, Object> put( "key1", 1l )
.put( "key2", 2l )
.put( "key3", 3l )
.put( "key4", 4l )
.buildAs()
.linkedHashMap();
public static int size(Map<?,?> map)
Map or 0 if the given Map reference is null.
map -
public static <K,V> V[] filteredValues(Map<K,V> map,
Class<V> valueType,
K... keys)
public static <E> Map<E,AtomicInteger> initializedCounterMap()
Map instance which returns for Map.get(Object) always an AtomicInteger instance. This
allows statements like:
Map<Object, AtomicInteger> map = MapUtils.initializedCounterMap(); int value1 = map.get( "lala" ).getAndIncrement(); int value2 = map.get( "lala" ).incrementAndGet(); assertEquals( 0, value1 ); assertEquals( 2, value2 );
public static <K,V> MapDelta<K,V> delta(Map<K,V> mapFirst,
Map<K,V> mapSecond)
MapDelta for the given two Map instances
mapFirst - mapSecond -
MapDeltaSetUtils.delta(Set, Set),
Mappublic static <K,V> AggregatedMap<K,V> aggregatedMap(Iterable<? extends Map<K,V>> mapIterable)
AggregatedMap for the given Maps
mapIterable -
AggregatedMap
public static <K,V> boolean putIfAbsent(Map<K,V> map,
K key,
V value)
Map only if there is no equal key already contained within the
Map.Map is null, the method does nothing.
map - Mapkey - value -
Map
public static <K,V> boolean putIfAbsent(Map<K,V> map,
K key,
Factory<V> valueFactory)
Map only if there is no equal key already contained within the
Map.Map.Map is null, the method does nothing.
map - Mapkey - valueFactory - Factory for a single value
Map
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||