Class TypePoolCreator<T>


  • public class TypePoolCreator<T>
    extends java.lang.Object
    Class that aids in building a pool of serialized types

    This class's purpose is to build the pool of all types and construct pointers into that pool.

    To add a new type to the pool or get a pointer to a type already in the pool, call typeToPointer(Object, Supplier). Once all types have been registered call generateTypePool().

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDisambiguationEdge​(com.google.javascript.jscomp.serialization.TypePointer subtype, com.google.javascript.jscomp.serialization.TypePointer supertype)
      Adds an edge from the given subtype to the given supertype if both are user-defined types and not native.
      static <T> TypePoolCreator<T> create​(SerializationOptions serializationOptions)
      Creates a new TypePoolCreator
      com.google.javascript.jscomp.serialization.TypePool generateTypePool()
      Generates a "type-pool" representing all the types that this class has encountered through calls to typeToPointer(Object, Supplier).
      com.google.javascript.jscomp.serialization.TypePointer typeToPointer​(T t, java.util.function.Supplier<com.google.javascript.jscomp.serialization.Type> serialize)
      Returns the type-pointer for the given AST-type, adding it to the type-pool if not present.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • generateTypePool

        public com.google.javascript.jscomp.serialization.TypePool generateTypePool()
        Generates a "type-pool" representing all the types that this class has encountered through calls to typeToPointer(Object, Supplier). After generation, no new types can be added, so subsequent calls to typeToPointer(Object, Supplier) can only be used to retrieve pointers to existing types in the type pool.
      • typeToPointer

        public com.google.javascript.jscomp.serialization.TypePointer typeToPointer​(T t,
                                                                                    java.util.function.Supplier<com.google.javascript.jscomp.serialization.Type> serialize)
        Returns the type-pointer for the given AST-type, adding it to the type-pool if not present.

        The type-pointer is a reference that can be later used to look up the given type in the type-pool. This function memoizes type-pointers and can be safely called multiple times for a given type.

        The given serializer will be called only once per type during type pool generation.

      • addDisambiguationEdge

        public void addDisambiguationEdge​(com.google.javascript.jscomp.serialization.TypePointer subtype,
                                          com.google.javascript.jscomp.serialization.TypePointer supertype)
        Adds an edge from the given subtype to the given supertype if both are user-defined types and not native.