Class ViewSettings.Builder

Object
Builder
Enclosing class:
ViewSettings

public static class ViewSettings.Builder extends Object

View settings builder allows to construct instances of ViewSettings and serialize them into JSON format.

Builder is not thread-safe.

See Also:
  • Constructor Details

    • Builder

      public Builder()
      Creates an empty builder
    • Builder

      public Builder(@Nullable ViewSettings copyFrom)
      Creates a builder that copies the contents of an already existing ViewSettings instance.
      Parameters:
      copyFrom - view settings to copy
  • Method Details

    • getViews

      @Nullable public List<ViewSettings.AssociatedView.Builder> getViews()
      Returns:
      a copy of list of ViewSettings.AssociatedView.Builder, or null if no views have been added. Each individual builder is not copied but referenced in the resulting list.
    • setViews

      public void setViews(List<ViewSettings.AssociatedView.Builder> views)
      Sets a list of builders of associated views.
      Parameters:
      views - list of builders, or null to make the constructed view settings undefined.
    • build

      @NotNull public ViewSettings build()
      Constructs an instance of ViewSettings. If a builder for any of the associated views is invalid, that associated view record is ignored.
      Returns:
      an instance of ViewSettings
    • addViews

      public ViewSettings.Builder addViews(long... viewIds)
      Adds specified views to the list of associated views. Each view is available on every page ("menu" marker is set for all pages), and each view is not the default on any page ("default" marker is unset for all pages).
      Parameters:
      viewIds - a list of view IDs
      Returns:
      this builder
    • addView

      public ViewSettings.Builder addView(long viewId, boolean defaultView)
      Adds the specified view to the list of associated views, optionally making it the default for all pages. The view is made available on every page ("menu" marker is set for all pages), and if defaultView parameter is true, the view is also marked as the default for all pages ("default" marker is set for all pages).
      Parameters:
      viewId - view ID
      defaultView - if , the added view will be the default
      Returns:
      this builder
    • addView

      public ViewSettings.Builder addView(int index, long viewId, @Nullable Collection<StructurePage> menuPages, @Nullable Collection<StructurePage> defaultPages)

      Adds specified view to the list of associated views, or inserts it as a specific position in the list. The caller may specify on which pages the view is available in the drop-down list (via menuPages parameter), and on which pages the view is the default (via defaultPages parameter.

      Hint: to construct a collection of pages, use EnumSet.of(...).

      Parameters:
      index - the position in the list where to add the view, or -1 to add the view to the end of the list
      viewId - the ID of the view
      menuPages - a collection of pages on which this view is offered to the user, null or empty means all pages
      defaultPages - a collection of pages on which this view is the default, null or empty means no pages
      Returns:
      this builder
      Throws:
      IndexOutOfBoundsException - if the specified index is invalid
    • makeDefined

      public void makeDefined()
      Makes this view settings instance defined, by making sure the views list is not null. Even if you don't add any views after that and build an instance of ViewSettings, the instance will be defined and override the default settings.
    • isDefined

      public boolean isDefined()
      Returns:
      true if the current state of the builder would create a defined instance of view settings
    • toString

      public String toString()
      Overrides:
      toString in class Object