Package org.ow2.authzforce.core.pdp.api
Class DefaultHashCollectionFactory
- java.lang.Object
-
- org.ow2.authzforce.core.pdp.api.DefaultHashCollectionFactory
-
- All Implemented Interfaces:
HashCollectionFactory
public final class DefaultHashCollectionFactory extends Object implements HashCollectionFactory
Default implementation ofHashCollectionFactory
based on Guava and native Java API. Default expected size is same as for Java API nativeHashMap
/HashSet
. This implementation does not distinguish mutable from immutable Map, contrary to Koloboke for instance, therefore the returned Map implementation fornewMutableMap()
andnewUpdatableMap()
method variants is the same.
-
-
Constructor Summary
Constructors Constructor Description DefaultHashCollectionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <K,V>
Map<K,V>newImmutableMap(Map<? extends K,? extends V> map)
Constructs a new immutable map with the same mappings as the specified map.<K,V>
Map<K,V>newImmutableMap(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Constructs a new immutable map which merges the mappings of the specified maps.<K,V>
Map<K,V>newImmutableMap(K k1, V v1)
Constructs a new immutable map of the single specified mapping.<K,V>
Map<K,V>newImmutableMap(K k1, V v1, K k2, V v2)
Constructs a new immutable map of the two specified mappings.<K,V>
Map<K,V>newImmutableMap(K k1, V v1, K k2, V v2, K k3, V v3)
Constructs a new immutable map of the three specified mappings.<E> Set<E>
newImmutableSet(E e1)
Constructs a new immutable singleton set of the given element.<E> Set<E>
newImmutableSet(E[] elements)
Constructs a new immutable set of elements from the given array.<E> Set<E>
newImmutableSet(Iterable<? extends E> elements)
Constructs a new immutable set containing the elements in the specified iterable.<E> Set<E>
newImmutableSet(Set<? extends E> set1, Set<? extends E> set2)
Constructs a new immutable set which merges the elements of the specified sets.<K,V>
Map<K,V>newMutableMap()
Constructs a new empty mutable map of the default expected size (depending on the implementation).<K,V>
Map<K,V>newUpdatableMap()
Constructs a new empty updatable map of the default expected size (depending on the underlying implementation).<K,V>
Map<K,V>newUpdatableMap(int expectedSize)
Constructs a new empty updatable map of the given expected size.<K,V>
Map<K,V>newUpdatableMap(Map<? extends K,? extends V> map)
Constructs a new updatable map with the same mappings as the specified map.<K,V>
Map<K,V>newUpdatableMap(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Constructs a new updatable map which merge the mappings of the specified maps.<K,V>
Map<K,V>newUpdatableMap(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2, Map<? extends K,? extends V> map3)
Constructs a new updatable map which merge the mappings of the specified maps.<E> Set<E>
newUpdatableSet()
Constructs a new empty updatable set of the default expected size (depending on the underlying implementation).<E> Set<E>
newUpdatableSet(int expectedSize)
Constructs a new empty updatable set of the given expected size.<E> Set<E>
newUpdatableSet(Iterable<? extends E> elements)
Constructs a new updatable set containing the elements in the specified iterable.
-
-
-
Method Detail
-
newMutableMap
public <K,V> Map<K,V> newMutableMap()
Description copied from interface:HashCollectionFactory
Constructs a new empty mutable map of the default expected size (depending on the implementation).- Specified by:
newMutableMap
in interfaceHashCollectionFactory
- Returns:
- a new empty mutable map
-
newUpdatableMap
public <K,V> Map<K,V> newUpdatableMap()
Description copied from interface:HashCollectionFactory
Constructs a new empty updatable map of the default expected size (depending on the underlying implementation).- Specified by:
newUpdatableMap
in interfaceHashCollectionFactory
- Returns:
- new empty updatable map
-
newUpdatableMap
public <K,V> Map<K,V> newUpdatableMap(int expectedSize)
Description copied from interface:HashCollectionFactory
Constructs a new empty updatable map of the given expected size.- Specified by:
newUpdatableMap
in interfaceHashCollectionFactory
- Parameters:
expectedSize
- expected size of the returned map- Returns:
- a new empty updatable map of the given expected size (positive)
-
newUpdatableMap
public <K,V> Map<K,V> newUpdatableMap(Map<? extends K,? extends V> map)
Description copied from interface:HashCollectionFactory
Constructs a new updatable map with the same mappings as the specified map.- Specified by:
newUpdatableMap
in interfaceHashCollectionFactory
- Parameters:
map
- the map whose mappings are to be placed in the returned map- Returns:
- a new updatable map with the same mappings as the specified map
-
newUpdatableMap
public <K,V> Map<K,V> newUpdatableMap(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Description copied from interface:HashCollectionFactory
Constructs a new updatable map which merge the mappings of the specified maps. On conflict, mappings from the map2 have priority over mappings from the map1 with the same keys.- Specified by:
newUpdatableMap
in interfaceHashCollectionFactory
- Parameters:
map1
- the first map to mergemap2
- the second map to merge- Returns:
- a new updatable map which merges the mappings of the specified maps
-
newUpdatableMap
public <K,V> Map<K,V> newUpdatableMap(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2, Map<? extends K,? extends V> map3)
Description copied from interface:HashCollectionFactory
Constructs a new updatable map which merge the mappings of the specified maps. On conflict, mappings from the maps passed later in the argument list have priority over mappings from the maps passed earlier with the same keys.- Specified by:
newUpdatableMap
in interfaceHashCollectionFactory
- Parameters:
map1
- the first map to mergemap2
- the second map to mergemap3
- the third map to merge- Returns:
- a new updatable map which merges the mappings of the specified maps
-
newImmutableMap
public <K,V> Map<K,V> newImmutableMap(Map<? extends K,? extends V> map)
Description copied from interface:HashCollectionFactory
Constructs a new immutable map with the same mappings as the specified map.- Specified by:
newImmutableMap
in interfaceHashCollectionFactory
- Parameters:
map
- the map whose mappings are to be placed in the returned map- Returns:
- a new immutable map with the same mappings as the specified map
-
newImmutableMap
public <K,V> Map<K,V> newImmutableMap(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Description copied from interface:HashCollectionFactory
Constructs a new immutable map which merges the mappings of the specified maps. On conflict, mappings from the map2 have priority over mappings from the map1 with the same keys.- Specified by:
newImmutableMap
in interfaceHashCollectionFactory
- Parameters:
map1
- the first map to mergemap2
- the second map to merge- Returns:
- a new immutable map which merges the mappings of the specified maps
-
newImmutableMap
public <K,V> Map<K,V> newImmutableMap(K k1, V v1)
Description copied from interface:HashCollectionFactory
Constructs a new immutable map of the single specified mapping.- Specified by:
newImmutableMap
in interfaceHashCollectionFactory
- Parameters:
k1
- the key of the sole mappingv1
- the value of the sole mapping- Returns:
- a new immutable map of the single specified mapping
-
newImmutableMap
public <K,V> Map<K,V> newImmutableMap(K k1, V v1, K k2, V v2)
Description copied from interface:HashCollectionFactory
Constructs a new immutable map of the two specified mappings.- Specified by:
newImmutableMap
in interfaceHashCollectionFactory
- Parameters:
k1
- the key of the first mappingv1
- the value of the first mappingk2
- the key of the second mappingv2
- the value of the second mapping- Returns:
- Returns an immutable map containing the given entries, in order.
-
newImmutableMap
public <K,V> Map<K,V> newImmutableMap(K k1, V v1, K k2, V v2, K k3, V v3)
Description copied from interface:HashCollectionFactory
Constructs a new immutable map of the three specified mappings.- Specified by:
newImmutableMap
in interfaceHashCollectionFactory
- Parameters:
k1
- the key of the first mappingv1
- the value of the first mappingk2
- the key of the second mappingv2
- the value of the second mappingk3
- the key of the third mappingv3
- the value of the third mapping- Returns:
- Returns an immutable map containing the given entries, in order.
-
newUpdatableSet
public <E> Set<E> newUpdatableSet()
Description copied from interface:HashCollectionFactory
Constructs a new empty updatable set of the default expected size (depending on the underlying implementation).- Specified by:
newUpdatableSet
in interfaceHashCollectionFactory
- Returns:
- a new empty updatable set
-
newUpdatableSet
public <E> Set<E> newUpdatableSet(int expectedSize)
Description copied from interface:HashCollectionFactory
Constructs a new empty updatable set of the given expected size.- Specified by:
newUpdatableSet
in interfaceHashCollectionFactory
- Parameters:
expectedSize
- the expected size of the returned set- Returns:
- a new empty updatable set of the given expected size (positive)
-
newUpdatableSet
public <E> Set<E> newUpdatableSet(Iterable<? extends E> elements)
Description copied from interface:HashCollectionFactory
Constructs a new updatable set containing the elements in the specified iterable.- Specified by:
newUpdatableSet
in interfaceHashCollectionFactory
- Parameters:
elements
- the iterable whose elements are to be placed into the returned set- Returns:
- a new updatable set of the elements of the specified iterable
-
newImmutableSet
public <E> Set<E> newImmutableSet(E[] elements)
Description copied from interface:HashCollectionFactory
Constructs a new immutable set of elements from the given array.- Specified by:
newImmutableSet
in interfaceHashCollectionFactory
- Parameters:
elements
- the array whose elements are to be placed into the returned set- Returns:
- a new immutable set of elements from the given array
-
newImmutableSet
public <E> Set<E> newImmutableSet(Iterable<? extends E> elements)
Description copied from interface:HashCollectionFactory
Constructs a new immutable set containing the elements in the specified iterable.- Specified by:
newImmutableSet
in interfaceHashCollectionFactory
- Parameters:
elements
- the iterable whose elements are to be placed into the returned set- Returns:
- a new immutable set of the elements of the specified iterable
-
newImmutableSet
public <E> Set<E> newImmutableSet(Set<? extends E> set1, Set<? extends E> set2)
Description copied from interface:HashCollectionFactory
Constructs a new immutable set which merges the elements of the specified sets.- Specified by:
newImmutableSet
in interfaceHashCollectionFactory
- Parameters:
set1
- the first source of elements for the returned setset2
- the second source of elements for the returned set- Returns:
- a new immutable set which merges the elements of the specified sets
-
newImmutableSet
public <E> Set<E> newImmutableSet(E e1)
Description copied from interface:HashCollectionFactory
Constructs a new immutable singleton set of the given element.- Specified by:
newImmutableSet
in interfaceHashCollectionFactory
- Parameters:
e1
- the sole element- Returns:
- a new immutable singleton set of the given element
-
-