com.h3c.util

## Class SafeMap.Builder<K,V>

- java.lang.Object
- - com.h3c.util.SafeMap.Builder<K,V>

- Type Parameters:
    `K` - the type of keys maintained by this safe map
    `V` - the type of mapped values
  Enclosing class:
    SafeMap<K,V>

      public static class SafeMap.Builder<K,V>
      extends Object

  SafeMap builder class. Note that each method returns a reference to the builder instance, so that the method calls can be chained.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SafeMap.Builder(V defaultValue)` Builder constructor that requires a mandatory default value.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `SafeMap.Builder<K,V>` | `add(K key, V value)` Adds a key/value pair to the map.
    `SafeMap<K,V>` | `build()` Builds the safe map instance from this builder instance.
    `SafeMap.Builder<K,V>` | `defaultKey(K defaultKey)` An optional default key can be set on the map, to be returned when no mapping is found via `SafeMap.getFirstKey(V)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SafeMap.Builder

          public SafeMap.Builder(V defaultValue)

      Builder constructor that requires a mandatory default value.
      Parameters:
        `defaultValue` - the required default value for the map
      Throws:
        `NullPointerException` - if the default value is null

  - ### Method Detail

    - #### defaultKey

          public SafeMap.Builder<K,V> defaultKey(K defaultKey)

      An optional default key can be set on the map, to be returned when no mapping is found via `SafeMap.getFirstKey(V)`.
      Parameters:
        `defaultKey` - the default key
      Returns:
        self

    - #### add

          public SafeMap.Builder<K,V> add(K key,
                                 V value)

      Adds a key/value pair to the map.
      Parameters:
        `key` - the key
        `value` - the value
      Returns:
        self
      Throws:
        `NullPointerException` - if either parameter is null

    - #### build

          public SafeMap<K,V> build()

      Builds the safe map instance from this builder instance.
      Returns:
        a safe map instance (immutable)

Copyright © 2014. All Rights Reserved.