com.google.gwt.core.ext

## Class Generator

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

- Direct Known Subclasses:
    IncrementalGenerator

      public abstract class Generator
      extends java.lang.Object

  Generates source code for subclasses during deferred binding requests. Subclasses must be thread-safe.

  If annotated by `@RunsLocal`, a generator can minimize its impact on compilation speed. See `Generator.RunsLocal` for details.

  Resource reading should be done through the ResourceOracle in the provided GeneratorContext (not via ClassLoader.getResource(), File, or URL) so that Generator Resource dependencies can be detected and used to facilitate fast incremental recompiles.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Generator.RunsLocal` An optional annotation indicating that a Generator can be run with local information during incremental compilation.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Generator()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `escape(java.lang.String unescaped)` Escapes string content to be a valid string literal.
    `static java.lang.String` | `escapeClassName(java.lang.String unescapedString)` Returns an escaped version of a String that is valid as a Java class name. Illegal characters become "_" + the character integer padded to 5 digits like "_01234".
    `abstract java.lang.String` | `generate(TreeLogger logger, GeneratorContext context, java.lang.String typeName)` Generate a default constructible subclass of the requested type.

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

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

- - ### Constructor Detail

    - #### Generator

          public Generator()

  - ### Method Detail

    - #### escape

          public static java.lang.String escape(java.lang.String unescaped)

      Escapes string content to be a valid string literal.
      Returns:
        an escaped version of `unescaped`, suitable for being enclosed in double quotes in Java source

    - #### escapeClassName

          public static java.lang.String escapeClassName(java.lang.String unescapedString)

      Returns an escaped version of a String that is valid as a Java class name.
      Illegal characters become "_" + the character integer padded to 5 digits like "_01234". The padding prevents collisions like the following "_" + "123" + "4" = "_" + "1234". The "_" escape character is escaped to "__".

    - #### generate

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

      Generate a default constructible subclass of the requested type. The generator throws `UnableToCompleteException` if for any reason it cannot provide a substitute class
      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`