Class Platform


  • @GwtCompatible(emulated=true)
    final class Platform
    extends java.lang.Object
    Methods factored out so that they can be emulated differently in GWT.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Platform()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (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 <K,​V>
      java.util.Map<K,​V>
      newHashMapWithExpectedSize​(int expectedSize)
      Returns the platform preferred implementation of a map based on a hash table.
      (package private) static <E> java.util.Set<E> newHashSetWithExpectedSize​(int expectedSize)
      Returns the platform preferred implementation of a set based on a hash table.
      (package private) static <K,​V>
      java.util.Map<K,​V>
      newLinkedHashMapWithExpectedSize​(int expectedSize)
      Returns the platform preferred implementation of an insertion ordered map based on a hash table.
      (package private) static <E> java.util.Set<E> newLinkedHashSetWithExpectedSize​(int expectedSize)
      Returns the platform preferred implementation of an insertion ordered set based on a hash table.
      (package private) static <E> java.util.Set<E> preservesInsertionOrderOnAddsSet()
      Returns the platform preferred set implementation that preserves insertion order when used only for insertions.
      (package private) static <K,​V>
      java.util.Map<K,​V>
      preservesInsertionOrderOnPutsMap()
      Returns the platform preferred map implementation that preserves insertion order when used only for insertions.
      (package private) static int reduceExponentIfGwt​(int exponent)  
      (package private) static int reduceIterationsIfGwt​(int iterations)  
      (package private) static MapMaker tryWeakKeys​(MapMaker 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 Detail

      • Platform

        private Platform()
    • Method Detail

      • newHashMapWithExpectedSize

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

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

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

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

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

        static <E> java.util.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
      • 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.
      • reduceIterationsIfGwt

        static int reduceIterationsIfGwt​(int iterations)
      • reduceExponentIfGwt

        static int reduceExponentIfGwt​(int exponent)