Class BidiMap.Builder<K,V>
java.lang.Object
org.apache.juneau.commons.collections.BidiMap.Builder<K,V>
- Type Parameters:
K- The key type.V- The value type.
Builder class for
BidiMap.
Provides a fluent API for constructing bidirectional maps.
Example:
BidiMap<String,Integer>
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
add
Adds a key-value pair to this map.Null keys and values are allowed in the builder but will be filtered out during the
build()operation.- Parameters:
key- The key. Can benull .value- The value. Can benull .- Returns:
- This object.
- Throws:
IllegalArgumentException- if the value already exists mapped to a different key.
-
build
Builds a newBidiMapfrom the entries added to this builder.Null keys and values are automatically filtered out during construction.
- Returns:
- A new
BidiMapinstance.
-
unmodifiable
Makes the resulting map unmodifiable.When set, the built map will be wrapped with
Collections.unmodifiableMap(Map), preventing any modifications after construction.- Returns:
- This object.
-