com.google.gwt.core.ext

## Class IncrementalGenerator

- java.lang.Object
- - com.google.gwt.core.ext.Generator
  - - com.google.gwt.core.ext.IncrementalGenerator

-     public abstract class IncrementalGenerator
      extends Generator

  An extension to the `Generator` class which supports incremental generation. It adds a `generateIncrementally(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)` method.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.google.gwt.core.ext.Generator

      `Generator.RunsLocal`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IncrementalGenerator()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `generate(TreeLogger logger, GeneratorContext context, java.lang.String typeName)` This method overrides `Generator.generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)`, and is included only for backwards compatibility.
    `abstract RebindResult` | `generateIncrementally(TreeLogger logger, GeneratorContext context, java.lang.String typeName)` Incrementally generate a default constructible subclass of the requested type.
    `static RebindResult` | `generateNonIncrementally(TreeLogger logger, Generator generator, GeneratorContext context, java.lang.String typeName)` A static helper method to wrap a non-incremental generator's result.
    `abstract long` | `getVersionId()` Returns a version id for an IncrementalGenerator.

    - ### Methods inherited from class com.google.gwt.core.ext.Generator

      `escape, escapeClassName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IncrementalGenerator

          public IncrementalGenerator()

  - ### Method Detail

    - #### generateNonIncrementally

          public static RebindResult generateNonIncrementally(TreeLogger logger,
                                                              Generator generator,
                                                              GeneratorContext context,
                                                              java.lang.String typeName)
                                                       throws UnableToCompleteException

      A static helper method to wrap a non-incremental generator's result. It calls the generator's `Generator.generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)` method, and synthesizes a `RebindResult` instance to be returned.
      Parameters:
        `logger` - A TreeLogger
        `generator` - A non-incremental generator
        `context` - The generator context
        `typeName` - The type for which a subclass will be generated
      Returns:
        a RebindResult
      Throws:
        `UnableToCompleteException`

    - #### generate

          public final java.lang.String generate(TreeLogger logger,
                                                 GeneratorContext context,
                                                 java.lang.String typeName)
                                          throws UnableToCompleteException

      This method overrides `Generator.generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)`, and is included only for backwards compatibility. It wraps a call to `generateIncrementally(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)`. This method won't normally be called by the gwt rebind process, and it is declared final and can't be overridden. It is provided in support of existing applications and other generators which call this method directly, outside of the gwt framework.

      The passed in context is wrapped with an instance of `NonIncrementalGeneratorContext`, to ensure that no generator result caching is attempted, since the cached result will be ignored by callers of this method anyway.

      Specified by:
        `generate` in class `Generator`
      Parameters:
        `logger` - A TreeLogger
        `context` - The generator context
        `typeName` - The type for which a subclass will be generated
      Returns:
        the name of a subclass to substitute for the requested class, or return `null` to cause the requested type itself to be used
      Throws:
        `UnableToCompleteException`
      See Also:
        `Generator.generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)`

    - #### generateIncrementally

          public abstract RebindResult generateIncrementally(TreeLogger logger,
                                                             GeneratorContext context,
                                                             java.lang.String typeName)
                                                      throws UnableToCompleteException

      Incrementally generate a default constructible subclass of the requested type. The generator can use information from the context to make decisions on whether to incrementally reuse cached output from previous invocations.

      It returns a `RebindResult`, which contains a `RebindMode` field, which indicates whether to use previously cached output, newly generated output, or a partial mixture of both cached and newly generated output.

      The result also includes a field for the name of the subclass to substitute for the requested class. It may also contain extra client data added by specific generator implementations.

      This method throws an `UnableToCompleteException` if for any reason it cannot complete successfully.

      Parameters:
        `logger` - A TreeLogger
        `context` - The generator context
        `typeName` - The type for which a subclass will be generated
      Returns:
        a RebindResult
      Throws:
        `UnableToCompleteException`
      See Also:
        `RebindResult`, `RebindMode`

    - #### getVersionId

          public abstract long getVersionId()

      Returns a version id for an IncrementalGenerator. It is used by the system to invalidate `CachedGeneratorResult`'s that were generated by a different version of this generator. This is useful when new versions of a generator are developed, which might alter the structure of generated output, or alter semantics for cache reusability checking.

      It is the responsibility of the developer to maintain this version id consistently.

      Returns:
        a version id