Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit fa5ab71

Browse files
authored
#429 Document new BiMap support
2 parents 27e4b75 + a2153fb commit fa5ab71

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,24 @@ A <code>[Map][]</code> property called 'albums' would generate:
365365
| `clearAlbums()` | Removes all mappings from albums, leaving it empty. |
366366
| `albums()` | Returns an unmodifiable view of the map of albums. Changes to the map held by the builder will be reflected in this view. |
367367

368+
```java
369+
/** Returns a bimap of favourite albums by year. **/
370+
BiMap<Integer, String> albums();
371+
```
372+
373+
A <code>[BiMap][]</code> property called 'albums' would generate:
374+
375+
| Method | Description |
376+
|:------:| ----------- |
377+
| `putAlbums(int key, String value)` | Associates `key` with `value` in albums. Throws a NullPointerException if either parameter is null, or an IllegalArgumentException if `value` is already bound to a different key. Replaces any existing entry for `key`. |
378+
| `forcePutAlbums(int key, String value)` | Associates `key` with `value` in albums. Throws a NullPointerException if either parameter is null. Replaces any existing entry for both `key` _and_ `value`. _Override this method to implement [constraint checks](#defaults-and-constraints)._ |
379+
| `putAllAlbums(Map<? extends Integer, ? extends String> map)` | Associates all of `map`'s keys and values in albums. Throws a NullPointerException if the map is null or contains a null key or value. Replaces any existing mapping for all keys in `map`. Throws an IllegalArgumentException if an attempt to put any entry fails. |
380+
| `removeKeyFromAlbums(int key)` | Removes the mapping for `key` from albums. Throws a NullPointerException if the parameter is null. Does nothing if the key is not present. |
381+
| `removeValueFromAlbums(String value)` | Removes the mapping for `value` from albums. Throws a NullPointerException if the parameter is null. Does nothing if the value is not present. |
382+
| `mutateAlbums(​Consumer<BiMap<Integer, String>> mutator)` | Invokes the [Consumer] `mutator` with the bimap of albums. Throws a NullPointerException if `mutator` is null. As `mutator` is a void consumer, any value returned from a lambda will be ignored, so be careful not to call pure functions like [stream()] expecting the returned map to replace the existing map. |
383+
| `clearAlbums()` | Removes all mappings from albums, leaving it empty. |
384+
| `albums()` | Returns an unmodifiable view of the bimap of albums. Changes to the bimap held by the builder will be reflected in this view. |
385+
368386
```java
369387
/** Returns a multimap of all awards by year. **/
370388
SetMultimap<Integer, String> awards();
@@ -403,6 +421,7 @@ personBuilder
403421
[Stream]: https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html
404422
[Multiset]: https://github.com/google/guava/wiki/NewCollectionTypesExplained#multiset
405423
[Map]: http://docs.oracle.com/javase/tutorial/collections/interfaces/map.html
424+
[BiMap]: https://github.com/google/guava/wiki/NewCollectionTypesExplained#bimap
406425
[Multimap]: https://github.com/google/guava/wiki/NewCollectionTypesExplained#multimap
407426
[natural ordering]: https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html
408427
[sort]: http://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#sort-java.util.List-

0 commit comments

Comments
 (0)