Class Platform


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

      Fields 
      Modifier and Type Field Description
      private static java.util.logging.Logger logger  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Platform()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static void checkGwtRpcEnabled()  
      (package private) static <T> T[] copy​(java.lang.Object[] source, int from, int to, T[] arrayOfType)
      Equivalent to Arrays.copyOfRange(source, from, to, arrayOfType.getClass()).
      (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> java.util.Set<E> newConcurrentHashSet()
      Returns the platform preferred implementation of a thread-safe hash set.
      (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
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
    • 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.
      • newConcurrentHashSet

        static <E> java.util.Set<E> newConcurrentHashSet()
        Returns the platform preferred implementation of a thread-safe hash set.
      • 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
      • copy

        static <T> T[] copy​(java.lang.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.
      • reduceIterationsIfGwt

        static int reduceIterationsIfGwt​(int iterations)
      • reduceExponentIfGwt

        static int reduceExponentIfGwt​(int exponent)
      • checkGwtRpcEnabled

        static void checkGwtRpcEnabled()