Returns a new Dict containing the entries added so far. The result has the specified mutability; null means immutable.
(@Nullable Mutability mu)
| 538 | * mutability; null means immutable. |
| 539 | */ |
| 540 | public Dict<K, V> build(@Nullable Mutability mu) { |
| 541 | if (mu == null) { |
| 542 | mu = Mutability.IMMUTABLE; |
| 543 | } |
| 544 | |
| 545 | if (mu == Mutability.IMMUTABLE) { |
| 546 | if (items.isEmpty()) { |
| 547 | return empty(); |
| 548 | } |
| 549 | return new Dict<>(buildImmutableMap()); |
| 550 | } else { |
| 551 | return new Dict<>(mu, buildLinkedHashMap()); |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | private void populateMap(int n, BiConsumer<K, V> mapEntryConsumer) { |
| 556 | for (int i = 0; i < n; i++) { |