/** * Returns an immutable map containing the same entries as {@code map}, sorted by the natural * ordering of the keys. * * <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. * * <p>This method is not type-safe, as it may be called on a map with keys that are not mutually * comparable. * * @throws ClassCastException if the keys in {@code map} are not mutually comparable * @throws NullPointerException if any key or value in {@code map} is null * @throws IllegalArgumentException if any two keys are equal according to their natural ordering */ public static <K, V> ImmutableSortedMap<K, V> copyOf(Map<? extends K, ? extends V> map) { // Hack around K not being a subtype of Comparable. // Unsafe, see ImmutableSortedSetFauxverideShim. @SuppressWarnings("unchecked") Ordering<K> naturalOrder = (Ordering<K>) NATURAL_ORDER; return copyOfInternal(map, naturalOrder); }
/** * Returns an immutable map containing the same entries as {@code map}, with keys sorted by the * provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, sorted by the natural * ordering of the keys. * * <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. * * <p>This method is not type-safe, as it may be called on a map with keys that are not mutually * comparable. * * @throws ClassCastException if the keys in {@code map} are not mutually comparable * @throws NullPointerException if any key or value in {@code map} is null * @throws IllegalArgumentException if any two keys are equal according to their natural ordering */ public static <K, V> ImmutableSortedMap<K, V> copyOf(Map<? extends K, ? extends V> map) { // Hack around K not being a subtype of Comparable. // Unsafe, see ImmutableSortedSetFauxverideShim. @SuppressWarnings("unchecked") Ordering<K> naturalOrder = (Ordering<K>) NATURAL_ORDER; return copyOfInternal(map, naturalOrder); }
/** * Returns an immutable map containing the same entries as {@code map}, with keys sorted by the * provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is an * {@code ImmutableSortedMap}, it may be returned instead of a copy. * * @throws NullPointerException if any key or value in {@code map} is null * @throws IllegalArgumentException if any two keys are equal according to * the comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is an * {@code ImmutableSortedMap}, it may be returned instead of a copy. * * @throws NullPointerException if any key or value in {@code map} is null * @throws IllegalArgumentException if any two keys are equal according to * the comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is an * {@code ImmutableSortedMap}, it may be returned instead of a copy. * * @throws NullPointerException if any key or value in {@code map} is null * @throws IllegalArgumentException if any two keys are equal according to * the comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with keys sorted by the * provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with keys sorted by the * provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as {@code map}, with * keys sorted by the provided comparator. * * <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 * @throws IllegalArgumentException if any two keys are equal according to the * comparator */ public static <K, V> ImmutableSortedMap<K, V> copyOf( Map<? extends K, ? extends V> map, Comparator<? super K> comparator) { return copyOfInternal(map, checkNotNull(comparator)); }
/** * Returns an immutable map containing the same entries as the provided sorted * map, with the same ordering. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is an * {@code ImmutableSortedMap}, it may be returned instead of a copy. * * @throws NullPointerException if any key or value in {@code map} is null */ public static <K, V> ImmutableSortedMap<K, V> copyOfSorted( SortedMap<K, ? extends V> map) { // If map has a null comparator, the keys should have a natural ordering, // even though K doesn't explicitly implement Comparable. @SuppressWarnings("unchecked") Comparator<? super K> comparator = (map.comparator() == null) ? NATURAL_ORDER : map.comparator(); return copyOfInternal(map, comparator); }
/** * Returns an immutable map containing the same entries as the provided sorted * map, with the same ordering. * * <p><b>Note:</b> Despite what the method name suggests, if {@code map} is an * {@code ImmutableSortedMap}, it may be returned instead of a copy. * * @throws NullPointerException if any key or value in {@code map} is null */ public static <K, V> ImmutableSortedMap<K, V> copyOfSorted( SortedMap<K, ? extends V> map) { // If map has a null comparator, the keys should have a natural ordering, // even though K doesn't explicitly implement Comparable. @SuppressWarnings("unchecked") Comparator<? super K> comparator = (map.comparator() == null) ? NATURAL_ORDER : map.comparator(); return copyOfInternal(map, comparator); }