Package com.atlassian.bamboo.util
Class BambooMaps
- java.lang.Object
-
- com.atlassian.bamboo.util.BambooMaps
-
public class BambooMaps extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
Map<K,V>generateMap(@NotNull Set<K> keys, @NotNull com.google.common.base.Function<K,V> generator)
Convenience method for generating map out of set of keys, and value generator.static <K,V>
LinkedHashMap<K,V>mutableLinkedUniqueIndex(Iterable<? extends V> values, com.google.common.base.Function<? super V,? extends K> indexGenerator)
static <K,V>
Map<K,V>mutableUniqueIndex(Iterable<? extends V> values, com.google.common.base.Function<? super V,? extends K> indexGenerator)
static <K,V>
Map<K,V>newHashMapFrom(Iterable<? extends V> source, com.google.common.base.Function<V,Pair<K,V>> function)
static <K,V>
Map<K,V>newLinkedHashMapWithLimitedSize(int maxSize)
static <K,V>
@NotNull com.google.common.cache.CacheLoader<? super K,io.atlassian.fugue.Option<V>>nullMasquingLoader(com.google.common.cache.CacheLoader<? super K,? extends V> nullReturningLoader)
static <K,V>
VpopulateMap(@NotNull Map<K,V> map, V input, @NotNull com.google.common.base.Function<? super V,? extends K> indexGenerator)
Add entry to the map usingFunction
to generate a keystatic <K,V>
voidprune(@NotNull Map<K,V> map, @NotNull Predicate<Map.Entry<K,V>> predicate)
Removes entries that match the supplied predicatestatic <K,V>
voidputAll(Map<K,? super V> map, Iterable<Pair<K,V>> iterable)
-
-
-
Method Detail
-
newHashMapFrom
public static <K,V> Map<K,V> newHashMapFrom(Iterable<? extends V> source, com.google.common.base.Function<V,Pair<K,V>> function)
-
newLinkedHashMapWithLimitedSize
public static <K,V> Map<K,V> newLinkedHashMapWithLimitedSize(int maxSize)
-
mutableUniqueIndex
public static <K,V> Map<K,V> mutableUniqueIndex(Iterable<? extends V> values, com.google.common.base.Function<? super V,? extends K> indexGenerator)
-
mutableLinkedUniqueIndex
public static <K,V> LinkedHashMap<K,V> mutableLinkedUniqueIndex(Iterable<? extends V> values, com.google.common.base.Function<? super V,? extends K> indexGenerator)
-
populateMap
public static <K,V> V populateMap(@NotNull @NotNull Map<K,V> map, @NotNull V input, @NotNull @NotNull com.google.common.base.Function<? super V,? extends K> indexGenerator)
Add entry to the map usingFunction
to generate a key- Parameters:
map
- map that will get an extra elementinput
- element to be added to mapindexGenerator
- function that will generate key for a given element- Returns:
- same behavior as
Map.put(Object, Object)
-
nullMasquingLoader
@NotNull public static <K,V> @NotNull com.google.common.cache.CacheLoader<? super K,io.atlassian.fugue.Option<V>> nullMasquingLoader(com.google.common.cache.CacheLoader<? super K,? extends V> nullReturningLoader)
-
generateMap
public static <K,V> Map<K,V> generateMap(@NotNull @NotNull Set<K> keys, @NotNull @NotNull com.google.common.base.Function<K,V> generator)
Convenience method for generating map out of set of keys, and value generator. Should be used for small maps. For more sophisticated uses consider using Guava's CacheBuilder.
-
-