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

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

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

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

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

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

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

      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

      public @NonNull TurboStream.Builder template(@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

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

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

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

      public @NonNull TurboStream.Builder template(@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

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

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

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

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

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

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

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

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

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

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

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

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

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

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