Class EndpointModelPlugin

java.lang.Object
com.vaadin.hilla.parser.core.AbstractPlugin<PluginConfiguration>
com.vaadin.hilla.generator.model.EndpointModelPlugin
All Implemented Interfaces:
Plugin

public final class EndpointModelPlugin extends AbstractPlugin<PluginConfiguration>
Builds the model the TypeScript generator works from out of the browser callable classes, while the parser walks them.

The model is assembled from the Java signatures the walk carries, so it keeps the type each value comes from. Whether a value can be absent is the one thing taken from what the other plugins say about it, since resolving it from the annotations, the Kotlin metadata and the defaults of the project is their work.

That is why the plugin belongs first in the chain, although it reads what the others write: a composite plugin enters its plugins in order and exits them in the opposite one, so the first plugin is the last to see a node it is done with. Anywhere else, the nullability of a value would be read before the plugins which decide it have run, and an annotated value would be written as one which can be absent.

The plugin only collects: every other plugin sees the walk as it would without it.

  • Constructor Details

    • EndpointModelPlugin

      public EndpointModelPlugin()
  • Method Details

    • getGeneration

      public Generation getGeneration()
      Everything the last run of the parser found, which is what one generation of TypeScript is written from.
    • getEndpoints

      public List<EndpointModel> getEndpoints()
      The endpoints built by the last run of the parser.
    • getEntities

      public List<EntityModel> getEntities()
      The types the endpoints of the last run refer to, in the order the walk reached them.
    • getUnions

      public List<UnionModel> getUnions()
      The polymorphic types of the last run, each with the subtypes a value of it can be.

      A subtype accepting the discriminator of the subtypes below it is narrowed to its own value here, since a value of it would otherwise be a value of any of them as far as TypeScript is concerned. That is why the unions are built once the walk is over rather than while it runs: it is the subtypes which say what they accept.

    • enter

      public void enter(NodePath<?> nodePath)
      Description copied from interface: Plugin
      Called on the way into a node, before the nodes below it are walked, which is where a plugin says what it knows about the node before anything below it is known. A plugin which only says which nodes there are to walk has nothing to do here.
    • exit

      public void exit(NodePath<?> nodePath)
      Description copied from interface: Plugin
      Called on the way out of a node, once the nodes below it have been walked, which is where a plugin settles what depends on them. A composite plugin exits its plugins in the opposite order to the one it enters them in.