Class TurboStream.Builder

java.lang.Object
io.micronaut.views.turbo.TurboStream.Builder
Enclosing class:
TurboStream

public static class TurboStream.Builder extends Object
Turbo Stream Builder.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • targetCssQuerySelectorPattern

      @NonNull public @NonNull TurboStream.Builder targetCssQuerySelectorPattern(@Nullable @Nullable Pattern pattern)
      Parameters:
      pattern - HTML attributes validation Pattern
      Returns:
      The Builder
    • targetDomIdPattern

      @NonNull public @NonNull TurboStream.Builder targetDomIdPattern(@Nullable @Nullable Pattern pattern)
      Parameters:
      pattern - HTML attributes validation Pattern
      Returns:
      The Builder
    • action

      @NonNull public @NonNull TurboStream.Builder action(@NonNull @NonNull TurboStreamAction action)
      Parameters:
      action - Sets the Turbo Stream Action
      Returns:
      The Builder
    • targetDomId

      @NonNull public @NonNull TurboStream.Builder targetDomId(@NonNull @NonNull String targetDomId)
      Parameters:
      targetDomId - Target DOM ID
      Returns:
      The Builder
    • targetCssQuerySelector

      @NonNull public @NonNull TurboStream.Builder targetCssQuerySelector(@NonNull @NonNull String targetCssQuerySelector)
      Parameters:
      targetCssQuerySelector - Target CSS Query Selector
      Returns:
      The Builder
    • requestId

      @NonNull public @NonNull TurboStream.Builder requestId(@NonNull @NonNull String requestId)
      Parameters:
      requestId - request-id attribute, only relevant when action=refresh
      Returns:
      The Builder
    • childrenOnly

      @NonNull public @NonNull TurboStream.Builder childrenOnly(boolean childrenOnly)
      Parameters:
      childrenOnly - Morph only the children of the element designated by the target dom id.
      Returns:
      The Builder
    • template

      @NonNull public @NonNull TurboStream.Builder template(@NonNull @NonNull String view, Object model)
      Sets the template with a View and Model.
      Parameters:
      view - The View name
      model - The Model
      Returns:
      The Builder
    • templateView

      @NonNull public @NonNull TurboStream.Builder templateView(@NonNull @NonNull String templateView)
      Sets the template's view name.
      Parameters:
      templateView - The View name
      Returns:
      The Builder
    • templateModel

      @NonNull public @NonNull TurboStream.Builder templateModel(@NonNull @NonNull Object templateModel)
      Sets the template's model.
      Parameters:
      templateModel - template model.
      Returns:
      The Builder
    • template

      @NonNull public @NonNull TurboStream.Builder template(@NonNull @NonNull String html)
      Sets the Turbo template with a String. E.g. HTML.
      Parameters:
      html - The turbo template
      Returns:
      The Builder
    • template

      @NonNull public @NonNull TurboStream.Builder template(@NonNull @NonNull io.micronaut.core.io.Writable writable)
      Sets the Turbo template with a Writable.
      Parameters:
      writable - The template as a Writable.
      Returns:
      The Builder
    • append

      @NonNull public @NonNull TurboStream.Builder append()
      Sets the Turbo action as TurboStreamAction.APPEND.
      Returns:
      The Builder.
    • prepend

      @NonNull public @NonNull TurboStream.Builder prepend()
      Sets the Turbo action as TurboStreamAction.PREPEND.
      Returns:
      The Builder
    • update

      @NonNull public @NonNull TurboStream.Builder update()
      Sets the Turbo action as TurboStreamAction.UPDATE.
      Returns:
      The Builder
    • remove

      @NonNull public @NonNull TurboStream.Builder remove()
      Sets the Turbo action as TurboStreamAction.REMOVE.
      Returns:
      The Builder.
    • after

      @NonNull public @NonNull TurboStream.Builder after()
      Sets the Turbo action as TurboStreamAction.AFTER.
      Returns:
      The Builder.
    • before

      @NonNull public @NonNull TurboStream.Builder before()
      Sets the Turbo action as TurboStreamAction.BEFORE.
      Returns:
      the Builder
    • replace

      @NonNull public @NonNull TurboStream.Builder replace()
      Sets the Turbo action as TurboStreamAction.REPLACE.
      Returns:
      the Builder
    • morph

      @NonNull public @NonNull TurboStream.Builder morph()
      Sets the Turbo action as TurboStreamAction.MORPH.
      Returns:
      the Builder
    • refresh

      @NonNull public @NonNull TurboStream.Builder refresh()
      Sets the Turbo action as TurboStreamAction.REFRESH.
      Returns:
      the Builder
    • build

      @NonNull public @NonNull TurboStream build()
      Returns:
      Builds the TurboStream.
    • getTemplateView

      @NonNull public @NonNull Optional<String> getTemplateView()
      Returns:
      The TurboStream template view name.
    • getTemplateModel

      @NonNull public @NonNull Optional<Object> getTemplateModel()
      Returns:
      The TurboStream template model.
    • getTargetDomId

      @NonNull public @NonNull Optional<String> getTargetDomId()
      Returns:
      TurboFrame Target DOM ID.
    • getTargetCssQuerySelector

      @NonNull public @NonNull Optional<String> getTargetCssQuerySelector()
      Returns:
      TurboFrame Target DOM ID.
    • of

      @NonNull public static @NonNull Optional<TurboStream.Builder> of(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request, @NonNull @NonNull io.micronaut.http.HttpResponse<?> response)
      Creates a Turbo Stream builder if annotation TurboView is found in the route and the request is a turbo request.
      Parameters:
      request - HTTP Request
      response - HTTP Response
      Returns:
      Creates a Turbo Stream builder if annotation TurboView is found in the route and the request is a turbo request.