Class ViewSettings.Builder
Object
Builder
- Enclosing class:
- ViewSettings
View settings builder allows to construct instances of ViewSettings and serialize them
into JSON format.
Builder is not thread-safe.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder()Creates an empty builderBuilder(ViewSettings copyFrom) Creates a builder that copies the contents of an already existingViewSettingsinstance. -
Method Summary
Modifier and TypeMethodDescriptionaddView(int index, long viewId, Collection<StructurePage> menuPages, Collection<StructurePage> defaultPages) Adds specified view to the list of associated views, or inserts it as a specific position in the list.addView(long viewId, boolean defaultView) Adds the specified view to the list of associated views, optionally making it the default for all pages.addViews(long... viewIds) Adds specified views to the list of associated views.build()Constructs an instance ofViewSettings.getViews()booleanvoidMakes this view settings instance defined, by making sure the views list is notnull.voidSets a list of builders of associated views.toString()
-
Constructor Details
-
Builder
public Builder()Creates an empty builder -
Builder
Creates a builder that copies the contents of an already existingViewSettingsinstance.- Parameters:
copyFrom- view settings to copy
-
-
Method Details
-
getViews
- Returns:
- a copy of list of
ViewSettings.AssociatedView.Builder, ornullif no views have been added. Each individual builder is not copied but referenced in the resulting list.
-
setViews
Sets a list of builders of associated views.- Parameters:
views- list of builders, ornullto make the constructed view settings undefined.
-
build
Constructs an instance ofViewSettings. If a builder for any of the associated views is invalid, that associated view record is ignored.- Returns:
- an instance of
ViewSettings
-
addViews
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
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 ifdefaultViewparameter istrue, the view is also marked as the default for all pages ("default" marker is set for all pages).- Parameters:
viewId- view IDdefaultView- 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
menuPagesparameter), and on which pages the view is the default (viadefaultPagesparameter.Hint: to construct a collection of pages, use
EnumSet.of(...).- Parameters:
index- the position in the list where to add the view, or-1to add the view to the end of the listviewId- the ID of the viewmenuPages- a collection of pages on which this view is offered to the user,nullor empty means all pagesdefaultPages- a collection of pages on which this view is the default,nullor 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 notnull. Even if you don't add any views after that and build an instance ofViewSettings, 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
-