Class ViewDef

java.lang.Object
org.apache.juneau.console.views.ViewDef

public final class ViewDef extends Object
A datatable view definition — an ordered set of Column definitions carrying each column's search configuration. This is the bean the VIEW_META search block is serialized from.

A view may also carry a table-level SearchOperatorSet: it is inherited by every column that does not supply its own set (see Column.effectiveOperators(SearchOperatorSet) and Column.searchMeta(SearchOperatorSet)). A column that supplies its own set entirely replaces the table-level set for that column.

Mutability

Deliberately mutable, like Column and RegionDef: a ViewDef is a server-side authoring bean built up once via fluent setters and column(Column) calls while constructing a view, not an immutable value object. Callers must not mutate one concurrently from more than one thread, and must not reuse one across requests unless every request treats it as read-only after construction.

Example:

// A view with a table-level $eq-only default, and one column ("status") that replaces it with $in-only. ViewDef view = ViewDef.create("releases") .operators(SearchOperatorSet.of(SearchOperatorSet.standard().get("$eq"))) .column(Column.create("name").label("Name").searchType(SearchType.TEXT)) .column(Column.create("status").label("Status").searchType(SearchType.ID) .operators(SearchOperatorSet.of(SearchOperatorSet.standard().get("$in"))));

See Also:
Since:
10.0.0
  • Method Details

    • create

      public static ViewDef create(String id)
      Starts a new view definition.
      Parameters:
      id - The view id (matches the datatable's id on the page). Must not be null or blank.
      Returns:
      A new, empty view definition.
      Throws:
      IllegalArgumentException - If id is null or blank.
    • column

      public ViewDef column(Column value)
      Adds a column definition, in order.
      Parameters:
      value - The column. Must not be null.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null.
    • operators

      Sets the table-level SearchOperatorSet — inherited by every column that does not supply its own set.
      Parameters:
      value - The operator set. Can be null to clear it (columns without their own set then fall back to SearchOperatorSet.standard()).
      Returns:
      This object.
    • id

      public String id()
      Returns:
      The view id.
    • columns

      public List<Column> columns()
      The column definitions, in insertion order.
      Returns:
      An unmodifiable list of the columns.
    • findColumn

      public Column findColumn(String name)
      Looks up a column by name.
      Parameters:
      name - The column name. Can be null.
      Returns:
      The column, or null if no column has that name.
    • operators

      This view's table-level operator set, or null if absent (columns without their own set fall back to SearchOperatorSet.standard()).
      Returns:
      The operator set, or null.