Class Platform

java.lang.Object
com.google.common.collect.Platform

final class Platform extends Object
Methods factored out so that they can be emulated differently in GWT.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static <T> T[]
    copy(Object[] source, int from, int to, T[] arrayOfType)
    Equivalent to Arrays.copyOfRange(source, from, to, arrayOfType.getClass()).
    (package private) static <E extends Enum<E>>
    Class<E>
     
    (package private) static <T> T[]
    newArray(T[] reference, int length)
    Returns a new array of the given length with the same type as a reference array.
    (package private) static <E> Set<E>
    Returns the platform preferred implementation of a thread-safe hash set.
    (package private) static <K, V> Map<K,V>
    newHashMapWithExpectedSize(int expectedSize)
    Returns the platform preferred implementation of a map based on a hash table.
    (package private) static <E> Set<E>
    newHashSetWithExpectedSize(int expectedSize)
    Returns the platform preferred implementation of a set based on a hash table.
    (package private) static <K, V> Map<K,V>
    Returns the platform preferred implementation of an insertion ordered map based on a hash table.
    (package private) static <E> Set<E>
    Returns the platform preferred implementation of an insertion ordered set based on a hash table.
    (package private) static <E> Set<E>
    Returns the platform preferred set implementation that preserves insertion order when used only for insertions.
    (package private) static <K, V> Map<K,V>
    Returns the platform preferred map implementation that preserves insertion order when used only for insertions.
    (package private) static <K, V> Map<K,V>
    Returns the platform preferred map implementation that preserves insertion order when used only for insertions, with a hint for how many entries to expect.
    (package private) static int
    reduceExponentIfGwt(int exponent)
     
    (package private) static int
    reduceIterationsIfGwt(int iterations)
     
    (package private) static MapMaker
    Configures the given map maker to use weak keys, if possible; does nothing otherwise (i.e., in GWT).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Platform

      private Platform()
  • Method Details

    • newHashMapWithExpectedSize

      static <K, V> Map<K,V> newHashMapWithExpectedSize(int expectedSize)
      Returns the platform preferred implementation of a map based on a hash table.
    • newLinkedHashMapWithExpectedSize

      static <K, V> Map<K,V> newLinkedHashMapWithExpectedSize(int expectedSize)
      Returns the platform preferred implementation of an insertion ordered map based on a hash table.
    • newHashSetWithExpectedSize

      static <E> Set<E> newHashSetWithExpectedSize(int expectedSize)
      Returns the platform preferred implementation of a set based on a hash table.
    • newConcurrentHashSet

      static <E> Set<E> newConcurrentHashSet()
      Returns the platform preferred implementation of a thread-safe hash set.
    • newLinkedHashSetWithExpectedSize

      static <E> Set<E> newLinkedHashSetWithExpectedSize(int expectedSize)
      Returns the platform preferred implementation of an insertion ordered set based on a hash table.
    • preservesInsertionOrderOnPutsMap

      static <K, V> Map<K,V> preservesInsertionOrderOnPutsMap()
      Returns the platform preferred map implementation that preserves insertion order when used only for insertions.
    • preservesInsertionOrderOnPutsMapWithExpectedSize

      static <K, V> Map<K,V> preservesInsertionOrderOnPutsMapWithExpectedSize(int expectedSize)
      Returns the platform preferred map implementation that preserves insertion order when used only for insertions, with a hint for how many entries to expect.
    • preservesInsertionOrderOnAddsSet

      static <E> Set<E> preservesInsertionOrderOnAddsSet()
      Returns the platform preferred set implementation that preserves insertion order when used only for insertions.
    • newArray

      static <T> T[] newArray(T[] reference, int length)
      Returns a new array of the given length with the same type as a reference array.
      Parameters:
      reference - any array of the desired type
      length - the length of the new array
    • copy

      static <T> T[] copy(Object[] source, int from, int to, T[] arrayOfType)
      Equivalent to Arrays.copyOfRange(source, from, to, arrayOfType.getClass()).
    • tryWeakKeys

      static MapMaker tryWeakKeys(MapMaker mapMaker)
      Configures the given map maker to use weak keys, if possible; does nothing otherwise (i.e., in GWT). This is sometimes acceptable, when only server-side code could generate enough volume that reclamation becomes important.
    • getDeclaringClassOrObjectForJ2cl

      static <E extends Enum<E>> Class<E> getDeclaringClassOrObjectForJ2cl(E e)
    • reduceIterationsIfGwt

      static int reduceIterationsIfGwt(int iterations)
    • reduceExponentIfGwt

      static int reduceExponentIfGwt(int exponent)