Class MapBuilder<K,V>

java.lang.Object
org.springframework.data.cassandra.util.MapBuilder<K,V>
Type Parameters:
K - The key type of the map.
V - The value type of the map.
All Implemented Interfaces:
Map<K,V>

public class MapBuilder<K,V> extends Object implements Map<K,V>
Builder for maps, which also conveniently implements Map via delegation for convenience so you don't have to actually build() it.
Author:
Matthew T. Adams, Mark Paluch
  • Constructor Details

    • MapBuilder

      public MapBuilder()
      Create a new MapBuilder.
    • MapBuilder

      public MapBuilder(Map<K,V> source)
      Create a new instance with a copy of the given map.
      Parameters:
      source - must not be null
  • Method Details

    • map

      public static MapBuilder<Object,Object> map()
      Factory method to construct a new MapBuilder. Convenient if imported statically.
    • map

      public static <K, V> MapBuilder<K,V> map(Class<K> keyType, Class<V> valueType)
      Factory method to construct a new builder with the given key & value types. Convenient if imported statically.
    • map

      public static <K, V> MapBuilder<K,V> map(Map<K,V> source)
      Factory method to construct a new builder with a shallow copy of the given map. Convenient if imported statically.
    • entry

      public MapBuilder<K,V> entry(K key, V value)
      Add an entry to this map, then returns this.
      Returns:
      this
    • build

      public Map<K,V> build()
      Return a new map based on the current state of this builder's map.
      Returns:
      a new Map with this builder's map's current content.
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • get

      @Nullable public V get(Object key)
      Specified by:
      get in interface Map<K,V>
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
    • remove

      @Nullable public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • equals

      public boolean equals(@Nullable Object o)
      Specified by:
      equals in interface Map<K,V>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class Object