001 /*
002 * Copyright (C) 2008 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package com.google.common.collect;
018
019 import static com.google.common.base.Preconditions.checkArgument;
020 import static com.google.common.base.Preconditions.checkNotNull;
021
022 import com.google.common.annotations.Beta;
023 import com.google.common.annotations.GwtCompatible;
024 import com.google.common.base.Function;
025 import com.google.common.base.Objects;
026 import com.google.common.base.Supplier;
027 import com.google.common.collect.Collections2.TransformedCollection;
028 import com.google.common.collect.Table.Cell;
029
030 import java.io.Serializable;
031 import java.util.Collection;
032 import java.util.Collections;
033 import java.util.Map;
034 import java.util.Set;
035 import java.util.SortedMap;
036 import java.util.SortedSet;
037
038 import javax.annotation.Nullable;
039
040 /**
041 * Provides static methods that involve a {@code Table}.
042 *
043 * @author Jared Levy
044 * @author Louis Wasserman
045 * @since 7.0
046 */
047 @GwtCompatible
048 @Beta
049 public final class Tables {
050 private Tables() {}
051
052 /**
053 * Returns an immutable cell with the specified row key, column key, and
054 * value.
055 *
056 * <p>The returned cell is serializable.
057 *
058 * @param rowKey the row key to be associated with the returned cell
059 * @param columnKey the column key to be associated with the returned cell
060 * @param value the value to be associated with the returned cell
061 */
062 public static <R, C, V> Cell<R, C, V> immutableCell(
063 @Nullable R rowKey, @Nullable C columnKey, @Nullable V value) {
064 return new ImmutableCell<R, C, V>(rowKey, columnKey, value);
065 }
066
067 static final class ImmutableCell<R, C, V>
068 extends AbstractCell<R, C, V> implements Serializable {
069 private final R rowKey;
070 private final C columnKey;
071 private final V value;
072
073 ImmutableCell(
074 @Nullable R rowKey, @Nullable C columnKey, @Nullable V value) {
075 this.rowKey = rowKey;
076 this.columnKey = columnKey;
077 this.value = value;
078 }
079
080 @Override
081 public R getRowKey() {
082 return rowKey;
083 }
084 @Override
085 public C getColumnKey() {
086 return columnKey;
087 }
088 @Override
089 public V getValue() {
090 return value;
091 }
092
093 private static final long serialVersionUID = 0;
094 }
095
096 abstract static class AbstractCell<R, C, V> implements Cell<R, C, V> {
097 // needed for serialization
098 AbstractCell() {}
099
100 @Override public boolean equals(Object obj) {
101 if (obj == this) {
102 return true;
103 }
104 if (obj instanceof Cell) {
105 Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
106 return Objects.equal(getRowKey(), other.getRowKey())
107 && Objects.equal(getColumnKey(), other.getColumnKey())
108 && Objects.equal(getValue(), other.getValue());
109 }
110 return false;
111 }
112
113 @Override public int hashCode() {
114 return Objects.hashCode(getRowKey(), getColumnKey(), getValue());
115 }
116
117 @Override public String toString() {
118 return "(" + getRowKey() + "," + getColumnKey() + ")=" + getValue();
119 }
120 }
121
122 /**
123 * Creates a transposed view of a given table that flips its row and column
124 * keys. In other words, calling {@code get(columnKey, rowKey)} on the
125 * generated table always returns the same value as calling {@code
126 * get(rowKey, columnKey)} on the original table. Updating the original table
127 * changes the contents of the transposed table and vice versa.
128 *
129 * <p>The returned table supports update operations as long as the input table
130 * supports the analogous operation with swapped rows and columns. For
131 * example, in a {@link HashBasedTable} instance, {@code
132 * rowKeySet().iterator()} supports {@code remove()} but {@code
133 * columnKeySet().iterator()} doesn't. With a transposed {@link
134 * HashBasedTable}, it's the other way around.
135 */
136 public static <R, C, V> Table<C, R, V> transpose(Table<R, C, V> table) {
137 return (table instanceof TransposeTable)
138 ? ((TransposeTable<R, C, V>) table).original
139 : new TransposeTable<C, R, V>(table);
140 }
141
142 private static class TransposeTable<C, R, V> implements Table<C, R, V> {
143 final Table<R, C, V> original;
144
145 TransposeTable(Table<R, C, V> original) {
146 this.original = checkNotNull(original);
147 }
148
149 @Override
150 public void clear() {
151 original.clear();
152 }
153
154 @Override
155 public Map<C, V> column(R columnKey) {
156 return original.row(columnKey);
157 }
158
159 @Override
160 public Set<R> columnKeySet() {
161 return original.rowKeySet();
162 }
163
164 @Override
165 public Map<R, Map<C, V>> columnMap() {
166 return original.rowMap();
167 }
168
169 @Override
170 public boolean contains(
171 @Nullable Object rowKey, @Nullable Object columnKey) {
172 return original.contains(columnKey, rowKey);
173 }
174
175 @Override
176 public boolean containsColumn(@Nullable Object columnKey) {
177 return original.containsRow(columnKey);
178 }
179
180 @Override
181 public boolean containsRow(@Nullable Object rowKey) {
182 return original.containsColumn(rowKey);
183 }
184
185 @Override
186 public boolean containsValue(@Nullable Object value) {
187 return original.containsValue(value);
188 }
189
190 @Override
191 public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
192 return original.get(columnKey, rowKey);
193 }
194
195 @Override
196 public boolean isEmpty() {
197 return original.isEmpty();
198 }
199
200 @Override
201 public V put(C rowKey, R columnKey, V value) {
202 return original.put(columnKey, rowKey, value);
203 }
204
205 @Override
206 public void putAll(Table<? extends C, ? extends R, ? extends V> table) {
207 original.putAll(transpose(table));
208 }
209
210 @Override
211 public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
212 return original.remove(columnKey, rowKey);
213 }
214
215 @Override
216 public Map<R, V> row(C rowKey) {
217 return original.column(rowKey);
218 }
219
220 @Override
221 public Set<C> rowKeySet() {
222 return original.columnKeySet();
223 }
224
225 @Override
226 public Map<C, Map<R, V>> rowMap() {
227 return original.columnMap();
228 }
229
230 @Override
231 public int size() {
232 return original.size();
233 }
234
235 @Override
236 public Collection<V> values() {
237 return original.values();
238 }
239
240 @Override public boolean equals(@Nullable Object obj) {
241 if (obj == this) {
242 return true;
243 }
244 if (obj instanceof Table) {
245 Table<?, ?, ?> other = (Table<?, ?, ?>) obj;
246 return cellSet().equals(other.cellSet());
247 }
248 return false;
249 }
250
251 @Override public int hashCode() {
252 return cellSet().hashCode();
253 }
254
255 @Override public String toString() {
256 return rowMap().toString();
257 }
258
259 // Will cast TRANSPOSE_CELL to a type that always succeeds
260 private static final Function<Cell<?, ?, ?>, Cell<?, ?, ?>> TRANSPOSE_CELL =
261 new Function<Cell<?, ?, ?>, Cell<?, ?, ?>>() {
262 @Override
263 public Cell<?, ?, ?> apply(Cell<?, ?, ?> cell) {
264 return immutableCell(
265 cell.getColumnKey(), cell.getRowKey(), cell.getValue());
266 }
267 };
268
269 CellSet cellSet;
270
271 @Override
272 public Set<Cell<C, R, V>> cellSet() {
273 CellSet result = cellSet;
274 return (result == null) ? cellSet = new CellSet() : result;
275 }
276
277 class CellSet extends TransformedCollection<Cell<R, C, V>, Cell<C, R, V>>
278 implements Set<Cell<C, R, V>> {
279 // Casting TRANSPOSE_CELL to a type that always succeeds
280 @SuppressWarnings("unchecked")
281 CellSet() {
282 super(original.cellSet(), (Function) TRANSPOSE_CELL);
283 }
284
285 @Override public boolean equals(Object obj) {
286 if (obj == this) {
287 return true;
288 }
289 if (!(obj instanceof Set)) {
290 return false;
291 }
292 Set<?> os = (Set<?>) obj;
293 if (os.size() != size()) {
294 return false;
295 }
296 return containsAll(os);
297 }
298
299 @Override public int hashCode() {
300 return Sets.hashCodeImpl(this);
301 }
302
303 @Override public boolean contains(Object obj) {
304 if (obj instanceof Cell) {
305 Cell<?, ?, ?> cell = (Cell<?, ?, ?>) obj;
306 return original.cellSet().contains(immutableCell(
307 cell.getColumnKey(), cell.getRowKey(), cell.getValue()));
308 }
309 return false;
310 }
311
312 @Override public boolean remove(Object obj) {
313 if (obj instanceof Cell) {
314 Cell<?, ?, ?> cell = (Cell<?, ?, ?>) obj;
315 return original.cellSet().remove(immutableCell(
316 cell.getColumnKey(), cell.getRowKey(), cell.getValue()));
317 }
318 return false;
319 }
320 }
321 }
322
323 /**
324 * Creates a table that uses the specified backing map and factory. It can
325 * generate a table based on arbitrary {@link Map} classes.
326 *
327 * <p>The {@code factory}-generated and {@code backingMap} classes determine
328 * the table iteration order. However, the table's {@code row()} method
329 * returns instances of a different class than {@code factory.get()} does.
330 *
331 * <p>Call this method only when the simpler factory methods in classes like
332 * {@link HashBasedTable} and {@link TreeBasedTable} won't suffice.
333 *
334 * <p>The views returned by the {@code Table} methods {@link Table#column},
335 * {@link Table#columnKeySet}, and {@link Table#columnMap} have iterators that
336 * don't support {@code remove()}. Otherwise, all optional operations are
337 * supported. Null row keys, columns keys, and values are not supported.
338 *
339 * <p>Lookups by row key are often faster than lookups by column key, because
340 * the data is stored in a {@code Map<R, Map<C, V>>}. A method call like
341 * {@code column(columnKey).get(rowKey)} still runs quickly, since the row key
342 * is provided. However, {@code column(columnKey).size()} takes longer, since
343 * an iteration across all row keys occurs.
344 *
345 * <p>Note that this implementation is not synchronized. If multiple threads
346 * access this table concurrently and one of the threads modifies the table,
347 * it must be synchronized externally.
348 *
349 * <p>The table is serializable if {@code backingMap}, {@code factory}, the
350 * maps generated by {@code factory}, and the table contents are all
351 * serializable.
352 *
353 * <p>Note: the table assumes complete ownership over of {@code backingMap}
354 * and the maps returned by {@code factory}. Those objects should not be
355 * manually updated and they should not use soft, weak, or phantom references.
356 *
357 * @param backingMap place to store the mapping from each row key to its
358 * corresponding column key / value map
359 * @param factory supplier of new, empty maps that will each hold all column
360 * key / value mappings for a given row key
361 * @throws IllegalArgumentException if {@code backingMap} is not empty
362 * @since 10.0
363 */
364 public static <R, C, V> Table<R, C, V> newCustomTable(
365 Map<R, Map<C, V>> backingMap, Supplier<? extends Map<C, V>> factory) {
366 checkArgument(backingMap.isEmpty());
367 checkNotNull(factory);
368 // TODO(jlevy): Wrap factory to validate that the supplied maps are empty?
369 return new StandardTable<R, C, V>(backingMap, factory);
370 }
371
372 /**
373 * Returns a view of a table where each value is transformed by a function.
374 * All other properties of the table, such as iteration order, are left
375 * intact.
376 *
377 * <p>Changes in the underlying table are reflected in this view. Conversely,
378 * this view supports removal operations, and these are reflected in the
379 * underlying table.
380 *
381 * <p>It's acceptable for the underlying table to contain null keys, and even
382 * null values provided that the function is capable of accepting null input.
383 * The transformed table might contain null values, if the function sometimes
384 * gives a null result.
385 *
386 * <p>The returned table is not thread-safe or serializable, even if the
387 * underlying table is.
388 *
389 * <p>The function is applied lazily, invoked when needed. This is necessary
390 * for the returned table to be a view, but it means that the function will be
391 * applied many times for bulk operations like {@link Table#containsValue} and
392 * {@code Table.toString()}. For this to perform well, {@code function} should
393 * be fast. To avoid lazy evaluation when the returned table doesn't need to
394 * be a view, copy the returned table into a new table of your choosing.
395 *
396 * @since 10.0
397 */
398 public static <R, C, V1, V2> Table<R, C, V2> transformValues(
399 Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
400 return new TransformedTable<R, C, V1, V2>(fromTable, function);
401 }
402
403 private static class TransformedTable<R, C, V1, V2>
404 implements Table<R, C, V2> {
405 final Table<R, C, V1> fromTable;
406 final Function<? super V1, V2> function;
407
408 TransformedTable(
409 Table<R, C, V1> fromTable, Function<? super V1, V2> function) {
410 this.fromTable = checkNotNull(fromTable);
411 this.function = checkNotNull(function);
412 }
413
414 @Override public boolean contains(Object rowKey, Object columnKey) {
415 return fromTable.contains(rowKey, columnKey);
416 }
417
418 @Override public boolean containsRow(Object rowKey) {
419 return fromTable.containsRow(rowKey);
420 }
421
422 @Override public boolean containsColumn(Object columnKey) {
423 return fromTable.containsColumn(columnKey);
424 }
425
426 @Override public boolean containsValue(Object value) {
427 return values().contains(value);
428 }
429
430 @Override public V2 get(Object rowKey, Object columnKey) {
431 // The function is passed a null input only when the table contains a null
432 // value.
433 return contains(rowKey, columnKey)
434 ? function.apply(fromTable.get(rowKey, columnKey)) : null;
435 }
436
437 @Override public boolean isEmpty() {
438 return fromTable.isEmpty();
439 }
440
441 @Override public int size() {
442 return fromTable.size();
443 }
444
445 @Override public void clear() {
446 fromTable.clear();
447 }
448
449 @Override public V2 put(R rowKey, C columnKey, V2 value) {
450 throw new UnsupportedOperationException();
451 }
452
453 @Override public void putAll(
454 Table<? extends R, ? extends C, ? extends V2> table) {
455 throw new UnsupportedOperationException();
456 }
457
458 @Override public V2 remove(Object rowKey, Object columnKey) {
459 return contains(rowKey, columnKey)
460 ? function.apply(fromTable.remove(rowKey, columnKey)) : null;
461 }
462
463 @Override public Map<C, V2> row(R rowKey) {
464 return Maps.transformValues(fromTable.row(rowKey), function);
465 }
466
467 @Override public Map<R, V2> column(C columnKey) {
468 return Maps.transformValues(fromTable.column(columnKey), function);
469 }
470
471 Function<Cell<R, C, V1>, Cell<R, C, V2>> cellFunction() {
472 return new Function<Cell<R, C, V1>, Cell<R, C, V2>>() {
473 @Override public Cell<R, C, V2> apply(Cell<R, C, V1> cell) {
474 return immutableCell(
475 cell.getRowKey(), cell.getColumnKey(),
476 function.apply(cell.getValue()));
477 }
478 };
479 }
480
481 class CellSet extends TransformedCollection<Cell<R, C, V1>, Cell<R, C, V2>>
482 implements Set<Cell<R, C, V2>> {
483 CellSet() {
484 super(fromTable.cellSet(), cellFunction());
485 }
486 @Override public boolean equals(Object obj) {
487 return Sets.equalsImpl(this, obj);
488 }
489 @Override public int hashCode() {
490 return Sets.hashCodeImpl(this);
491 }
492 @Override public boolean contains(Object obj) {
493 if (obj instanceof Cell) {
494 Cell<?, ?, ?> cell = (Cell<?, ?, ?>) obj;
495 if (!Objects.equal(
496 cell.getValue(), get(cell.getRowKey(), cell.getColumnKey()))) {
497 return false;
498 }
499 return cell.getValue() != null
500 || fromTable.contains(cell.getRowKey(), cell.getColumnKey());
501 }
502 return false;
503 }
504 @Override public boolean remove(Object obj) {
505 if (contains(obj)) {
506 Cell<?, ?, ?> cell = (Cell<?, ?, ?>) obj;
507 fromTable.remove(cell.getRowKey(), cell.getColumnKey());
508 return true;
509 }
510 return false;
511 }
512 }
513
514 CellSet cellSet;
515
516 @Override public Set<Cell<R, C, V2>> cellSet() {
517 return (cellSet == null) ? cellSet = new CellSet() : cellSet;
518 }
519
520 @Override public Set<R> rowKeySet() {
521 return fromTable.rowKeySet();
522 }
523
524 @Override public Set<C> columnKeySet() {
525 return fromTable.columnKeySet();
526 }
527
528 Collection<V2> values;
529
530 @Override public Collection<V2> values() {
531 return (values == null)
532 ? values = Collections2.transform(fromTable.values(), function)
533 : values;
534 }
535
536 Map<R, Map<C, V2>> createRowMap() {
537 Function<Map<C, V1>, Map<C, V2>> rowFunction =
538 new Function<Map<C, V1>, Map<C, V2>>() {
539 @Override public Map<C, V2> apply(Map<C, V1> row) {
540 return Maps.transformValues(row, function);
541 }
542 };
543 return Maps.transformValues(fromTable.rowMap(), rowFunction);
544 }
545
546 Map<R, Map<C, V2>> rowMap;
547
548 @Override public Map<R, Map<C, V2>> rowMap() {
549 return (rowMap == null) ? rowMap = createRowMap() : rowMap;
550 }
551
552 Map<C, Map<R, V2>> createColumnMap() {
553 Function<Map<R, V1>, Map<R, V2>> columnFunction =
554 new Function<Map<R, V1>, Map<R, V2>>() {
555 @Override public Map<R, V2> apply(Map<R, V1> column) {
556 return Maps.transformValues(column, function);
557 }
558 };
559 return Maps.transformValues(fromTable.columnMap(), columnFunction);
560 }
561
562 Map<C, Map<R, V2>> columnMap;
563
564 @Override public Map<C, Map<R, V2>> columnMap() {
565 return (columnMap == null) ? columnMap = createColumnMap() : columnMap;
566 }
567
568 @Override public boolean equals(@Nullable Object obj) {
569 if (obj == this) {
570 return true;
571 }
572 if (obj instanceof Table) {
573 Table<?, ?, ?> other = (Table<?, ?, ?>) obj;
574 return cellSet().equals(other.cellSet());
575 }
576 return false;
577 }
578
579 @Override public int hashCode() {
580 return cellSet().hashCode();
581 }
582
583 @Override public String toString() {
584 return rowMap().toString();
585 }
586 }
587
588 /**
589 * Returns an unmodifiable view of the specified table. This method allows modules to provide
590 * users with "read-only" access to internal tables. Query operations on the returned table
591 * "read through" to the specified table, and attempts to modify the returned table, whether
592 * direct or via its collection views, result in an {@code UnsupportedOperationException}.
593 *
594 * <p>The returned table will be serializable if the specified table is serializable.
595 *
596 * <p>Consider using an {@link ImmutableTable}, which is guaranteed never to change.
597 *
598 * @param table
599 * the table for which an unmodifiable view is to be returned
600 * @return an unmodifiable view of the specified table
601 * @since 11.0
602 */
603 public static <R, C, V> Table<R, C, V> unmodifiableTable(
604 Table<? extends R, ? extends C, ? extends V> table) {
605 return new UnmodifiableTable<R, C, V>(table);
606 }
607
608 private static class UnmodifiableTable<R, C, V>
609 extends ForwardingTable<R, C, V> implements Serializable {
610 final Table<? extends R, ? extends C, ? extends V> delegate;
611
612 UnmodifiableTable(Table<? extends R, ? extends C, ? extends V> delegate) {
613 this.delegate = checkNotNull(delegate);
614 }
615
616 @SuppressWarnings("unchecked") // safe, covariant cast
617 @Override
618 protected Table<R, C, V> delegate() {
619 return (Table<R, C, V>) delegate;
620 }
621
622 @Override
623 public Set<Cell<R, C, V>> cellSet() {
624 return Collections.unmodifiableSet(super.cellSet());
625 }
626
627 @Override
628 public void clear() {
629 throw new UnsupportedOperationException();
630 }
631
632 @Override
633 public Map<R, V> column(@Nullable C columnKey) {
634 return Collections.unmodifiableMap(super.column(columnKey));
635 }
636
637 @Override
638 public Set<C> columnKeySet() {
639 return Collections.unmodifiableSet(super.columnKeySet());
640 }
641
642 @Override
643 public Map<C, Map<R, V>> columnMap() {
644 Function<Map<R, V>, Map<R, V>> wrapper = unmodifiableWrapper();
645 return Collections.unmodifiableMap(Maps.transformValues(super.columnMap(), wrapper));
646 }
647
648 @Override
649 public V put(@Nullable R rowKey, @Nullable C columnKey, @Nullable V value) {
650 throw new UnsupportedOperationException();
651 }
652
653 @Override
654 public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
655 throw new UnsupportedOperationException();
656 }
657
658 @Override
659 public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
660 throw new UnsupportedOperationException();
661 }
662
663 @Override
664 public Map<C, V> row(@Nullable R rowKey) {
665 return Collections.unmodifiableMap(super.row(rowKey));
666 }
667
668 @Override
669 public Set<R> rowKeySet() {
670 return Collections.unmodifiableSet(super.rowKeySet());
671 }
672
673 @Override
674 public Map<R, Map<C, V>> rowMap() {
675 Function<Map<C, V>, Map<C, V>> wrapper = unmodifiableWrapper();
676 return Collections.unmodifiableMap(Maps.transformValues(super.rowMap(), wrapper));
677 }
678
679 @Override
680 public Collection<V> values() {
681 return Collections.unmodifiableCollection(super.values());
682 }
683
684 private static final long serialVersionUID = 0;
685 }
686
687 /**
688 * Returns an unmodifiable view of the specified row-sorted table. This method allows modules to
689 * provide users with "read-only" access to internal tables. Query operations on the returned
690 * table "read through" to the specified table, and attemps to modify the returned table, whether
691 * direct or via its collection views, result in an {@code UnsupportedOperationException}.
692 *
693 * <p>The returned table will be serializable if the specified table is serializable.
694 *
695 * @param table the row-sorted table for which an unmodifiable view is to be returned
696 * @return an unmodifiable view of the specified table
697 * @since 11.0
698 */
699 public static <R, C, V> RowSortedTable<R, C, V> unmodifiableRowSortedTable(
700 RowSortedTable<R, ? extends C, ? extends V> table) {
701 /*
702 * It's not ? extends R, because it's technically not covariant in R. Specifically,
703 * table.rowMap().comparator() could return a comparator that only works for the ? extends R.
704 * Collections.unmodifiableSortedMap makes the same distinction.
705 */
706 return new UnmodifiableRowSortedMap<R, C, V>(table);
707 }
708
709 static final class UnmodifiableRowSortedMap<R, C, V> extends UnmodifiableTable<R, C, V>
710 implements RowSortedTable<R, C, V> {
711
712 public UnmodifiableRowSortedMap(RowSortedTable<R, ? extends C, ? extends V> delegate) {
713 super(delegate);
714 }
715
716 @Override
717 protected RowSortedTable<R, C, V> delegate() {
718 return (RowSortedTable<R, C, V>) super.delegate();
719 }
720
721 @Override
722 public SortedMap<R, Map<C, V>> rowMap() {
723 Function<Map<C, V>, Map<C, V>> wrapper = unmodifiableWrapper();
724 return Collections.unmodifiableSortedMap(Maps.transformValues(delegate().rowMap(), wrapper));
725 }
726
727 @Override
728 public SortedSet<R> rowKeySet() {
729 return Collections.unmodifiableSortedSet(delegate().rowKeySet());
730 }
731
732 private static final long serialVersionUID = 0;
733 }
734
735 @SuppressWarnings("unchecked")
736 private static <K, V> Function<Map<K, V>, Map<K, V>> unmodifiableWrapper() {
737 return (Function) UNMODIFIABLE_WRAPPER;
738 }
739
740 private static final Function<? extends Map<?, ?>, ? extends Map<?, ?>> UNMODIFIABLE_WRAPPER =
741 new Function<Map<Object, Object>, Map<Object, Object>>() {
742 @Override
743 public Map<Object, Object> apply(Map<Object, Object> input) {
744 return Collections.unmodifiableMap(input);
745 }
746 };
747 }