/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally used * to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally used * to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally used * to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
@Override boolean isPartialView() { return map().isPartialView(); }
/** * Returns an immutable map containing the same entries as {@code map}. The returned map iterates * over entries in the same order as the {@code entrySet} of the original map. If {@code map} * somehow contains entries with duplicate keys (for example, if it is a {@code SortedMap} whose * comparator is not <i>consistent with equals</i>), the results of this method are undefined. * * <p>Despite the method name, this method attempts to avoid actually copying the data when it is * safe to do so. The exact circumstances under which a copy will or will not be performed are * undocumented and subject to change. * * @throws NullPointerException if any key or value in {@code map} is null */ public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) { if ((map instanceof ImmutableMap) && !(map instanceof SortedMap)) { @SuppressWarnings("unchecked") // safe since map is not writable ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) map; if (!kvMap.isPartialView()) { return kvMap; } } else if (map instanceof EnumMap) { @SuppressWarnings("unchecked") // safe since map is not writable ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) copyOfEnumMap((EnumMap<?, ?>) map); return kvMap; } return copyOf(map.entrySet()); }
@Override boolean isPartialView() { return map().isPartialView(); }
@Override boolean isPartialView() { return map().isPartialView(); }
/** * Returns an immutable map containing the same entries as {@code map}. The returned map iterates * over entries in the same order as the {@code entrySet} of the original map. If {@code map} * somehow contains entries with duplicate keys (for example, if it is a {@code SortedMap} whose * comparator is not <i>consistent with equals</i>), the results of this method are undefined. * * <p>Despite the method name, this method attempts to avoid actually copying the data when it is * safe to do so. The exact circumstances under which a copy will or will not be performed are * undocumented and subject to change. * * @throws NullPointerException if any key or value in {@code map} is null */ public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) { if ((map instanceof ImmutableMap) && !(map instanceof SortedMap)) { @SuppressWarnings("unchecked") // safe since map is not writable ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) map; if (!kvMap.isPartialView()) { return kvMap; } } else if (map instanceof EnumMap) { @SuppressWarnings("unchecked") // safe since map is not writable ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) copyOfEnumMap((EnumMap<?, ?>) map); return kvMap; } return copyOf(map.entrySet()); }
/** * A builder for creating immutable map instances, especially {@code public static final} maps * ("constant maps"). Example: * * <pre>{@code * static final ImmutableMap<String, Integer> WORD_TO_INT = * new ImmutableMap.Builder<String, Integer>() * .put("one", 1) * .put("two", 2) * .put("three", 3) * .build(); * }</pre> * * <p>For <i>small</i> immutable maps, the {@code ImmutableMap.of()} methods are even more * convenient. * * <p>By default, a {@code Builder} will generate maps that iterate over entries in the order they * were inserted into the builder, equivalently to {@code LinkedHashMap}. For example, in the * above example, {@code WORD_TO_INT.entrySet()} is guaranteed to iterate over the entries in the * order {@code "one"=1, "two"=2, "three"=3}, and {@code keySet()} and {@code values()} respect * the same order. If you want a different order, consider using {@link ImmutableSortedMap} to * sort by keys, or call {@link #orderEntriesByValue(Comparator)}, which changes this builder to * sort entries by value. * * <p>Builder instances can be reused - it is safe to call {@link #build} multiple times to build * multiple maps in series. Each map is a superset of the maps created before it. * * @since 2.0 */ public static class Builder<K, V> {
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally * used to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally * used to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally * used to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally * used to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally used * to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally * used to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally * used to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally used * to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
/** * Returns {@code true} if this immutable multimap's implementation contains references to * user-created objects that aren't accessible via this multimap's methods. This is generally * used to determine whether {@code copyOf} implementations should make an explicit copy to avoid * memory leaks. */ boolean isPartialView() { return map.isPartialView(); }
@Override boolean isPartialView() { return delegate.isPartialView() || inverse.delegate().isPartialView(); } }
@Override boolean isPartialView() { return map().isPartialView(); }