Interface HashCollectionFactory

All Known Implementing Classes:
DefaultHashCollectionFactory

public interface HashCollectionFactory
Factory method to construct HashMaps/HashSets. Implement this interface to allow AuthZForce code to use alternatives to Java native implementations, which alternatives must support:
  1. Immutable HashMap/HashSet implementations.
  2. Mutable HashMap/HashSet implementations accepting an expected size as constructor parameter.
Ideally, the alternative should support updatable HashMaps/HashSets accepting an expected size as constructor parameter as well.
  • Method Summary

    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>
    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>
    Constructs a new empty mutable map of the default expected size (depending on the implementation).
    <K, V> Map<K,V>
    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>
    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 Details

    • newMutableMap

      <K, V> Map<K,V> newMutableMap()
      Constructs a new empty mutable map of the default expected size (depending on the implementation).
      Type Parameters:
      K - key type
      V - value type
      Returns:
      a new empty mutable map
    • newUpdatableMap

      <K, V> Map<K,V> newUpdatableMap()
      Constructs a new empty updatable map of the default expected size (depending on the underlying implementation).
      Type Parameters:
      K - key type
      V - value type
      Returns:
      new empty updatable map
    • newUpdatableMap

      <K, V> Map<K,V> newUpdatableMap(int expectedSize) throws IllegalArgumentException
      Constructs a new empty updatable map of the given expected size.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      expectedSize - expected size of the returned map
      Returns:
      a new empty updatable map of the given expected size (positive)
      Throws:
      IllegalArgumentException - if expectedSize is negative
    • newUpdatableMap

      <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.
      Type Parameters:
      K - key type
      V - value type
      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

      <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. On conflict, mappings from the map2 have priority over mappings from the map1 with the same keys.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      map1 - the first map to merge
      map2 - the second map to merge
      Returns:
      a new updatable map which merges the mappings of the specified maps
    • newUpdatableMap

      <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. 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.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      map1 - the first map to merge
      map2 - the second map to merge
      map3 - the third map to merge
      Returns:
      a new updatable map which merges the mappings of the specified maps
    • newImmutableMap

      <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.
      Type Parameters:
      K - key type
      V - value type
      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

      <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. On conflict, mappings from the map2 have priority over mappings from the map1 with the same keys.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      map1 - the first map to merge
      map2 - the second map to merge
      Returns:
      a new immutable map which merges the mappings of the specified maps
    • newImmutableMap

      <K, V> Map<K,V> newImmutableMap(K k1, V v1)
      Constructs a new immutable map of the single specified mapping.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      k1 - the key of the sole mapping
      v1 - the value of the sole mapping
      Returns:
      a new immutable map of the single specified mapping
    • newImmutableMap

      <K, V> Map<K,V> newImmutableMap(K k1, V v1, K k2, V v2)
      Constructs a new immutable map of the two specified mappings.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      k1 - the key of the first mapping
      v1 - the value of the first mapping
      k2 - the key of the second mapping
      v2 - the value of the second mapping
      Returns:
      Returns an immutable map containing the given entries, in order.
    • newImmutableMap

      <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.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      k1 - the key of the first mapping
      v1 - the value of the first mapping
      k2 - the key of the second mapping
      v2 - the value of the second mapping
      k3 - the key of the third mapping
      v3 - the value of the third mapping
      Returns:
      Returns an immutable map containing the given entries, in order.
    • newUpdatableSet

      <E> Set<E> newUpdatableSet()
      Constructs a new empty updatable set of the default expected size (depending on the underlying implementation).
      Type Parameters:
      E - set element type
      Returns:
      a new empty updatable set
    • newUpdatableSet

      <E> Set<E> newUpdatableSet(int expectedSize) throws IllegalArgumentException
      Constructs a new empty updatable set of the given expected size.
      Type Parameters:
      E - set element type
      Parameters:
      expectedSize - the expected size of the returned set
      Returns:
      a new empty updatable set of the given expected size (positive)
      Throws:
      IllegalArgumentException - if expectedSize is negative
    • newUpdatableSet

      <E> Set<E> newUpdatableSet(Iterable<? extends E> elements)
      Constructs a new updatable set containing the elements in the specified iterable.
      Type Parameters:
      E - element type
      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

      <E> Set<E> newImmutableSet(E[] elements)
      Constructs a new immutable set of elements from the given array.
      Type Parameters:
      E - element type
      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

      <E> Set<E> newImmutableSet(Iterable<? extends E> elements)
      Constructs a new immutable set containing the elements in the specified iterable.
      Type Parameters:
      E - element type
      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

      <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.
      Type Parameters:
      E - element type
      Parameters:
      set1 - the first source of elements for the returned set
      set2 - the second source of elements for the returned set
      Returns:
      a new immutable set which merges the elements of the specified sets
    • newImmutableSet

      <E> Set<E> newImmutableSet(E e1)
      Constructs a new immutable singleton set of the given element.
      Type Parameters:
      E - element type
      Parameters:
      e1 - the sole element
      Returns:
      a new immutable singleton set of the given element