Class Column

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

public final class Column extends Object
One datatable column's search configuration — its value SearchType and the optional per-column SearchOperatorSet.
Operator gating

A column's offerable operators are modeled by a single SearchOperatorSet, never a string allow-list or a separate custom-operator map. A custom operator is simply a SearchOperator placed inside a set via SearchOperatorSet.standard(), SearchOperatorSet.with(SearchOperator), or SearchOperatorSet.of(SearchOperator...).

  • Set absent (default): the column offers the entire type-applicable standard universe (or, when resolved against a table, the table-level set — see ViewDef).
  • Set present (operators(SearchOperatorSet)): the column's set entirely replaces the table-level set for this column; the effective operators are that set's type-applicable members.

An operator not on the effective set is a reject (the popup marks it invalid), never a silent rewrite — see offers(String).

Mutability

Deliberately mutable, like ViewDef and RegionDef: a Column is a server-side authoring bean built up once via fluent setters while constructing a view definition, 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 searchable "status" column offering only $eq and $in, plus a custom "$mine" operator. Column status = Column.create("status") .label("Status") .searchType(SearchType.ID) .operators(SearchOperatorSet.of( SearchOperatorSet.standard().get("$eq"), SearchOperatorSet.standard().get("$in"), SearchOperator.create("$mine", "Assigned to me").types(SearchType.ID).build()));

See Also:
Since:
10.0.0
  • Method Details

    • create

      public static Column create(String name)
      Starts a new column definition.
      Parameters:
      name - The column name (matches the row-data key). Must not be null or blank.
      Returns:
      A new column, not searchable until a searchType(SearchType) is set.
      Throws:
      IllegalArgumentException - If name is null or blank.
    • label

      public Column label(String value)
      Sets the human-readable column label.
      Parameters:
      value - The label. Can be null.
      Returns:
      This object.
    • searchType

      public Column searchType(SearchType value)
      Sets the column's value type, which governs both leaf semantics and the offerable built-in operators. A column with no search type is not searchable.
      Parameters:
      value - The value type. Can be null to mark the column non-searchable.
      Returns:
      This object.
    • operators

      Sets this column's own SearchOperatorSet — it entirely replaces the table-level set for this column.
      Parameters:
      value - The operator set. A null value clears it back to absent (inherit the table-level set, or SearchOperatorSet.standard() when there is none).
      Returns:
      This object.
    • render

      public Column render(String spec)
      Sets this column's cell renderer from the compact "id:field" string sugar.
      Parameters:
      spec - The render-id string, e.g. "tag:status". Must not be null or blank.
      Returns:
      This object.
    • render

      public Column render(Render value)
      Sets this column's cell renderer.
      Parameters:
      value - The renderer. Can be null to unset.
      Returns:
      This object.
    • href

      public Column href(String template)
      Sets the row-data interpolation template this column's rendered cell links to.

      An href with no render implies render("linked"); the catalog entry (toCatalogMap()) carries that render. An explicit render always wins, whichever order the two are set in.

      Parameters:
      template - The href template, e.g. "{incidentUrl}". Can be null to unset.
      Returns:
      This object.
    • className

      public Column className(String css)
      Sets a CSS class applied to this column's cells.
      Parameters:
      css - The class name(s). Can be null to unset.
      Returns:
      This object.
    • defaultVisible

      public Column defaultVisible(boolean v)
      Sets whether this column starts visible.

      Defaults to true; only false is ever emitted by toCatalogMap().

      A false value only hides the column when the client's columnConfig (juneau-config.js) is on; without it the column stays visible.

      Parameters:
      v - Whether the column starts visible.
      Returns:
      This object.
    • toCatalogMap

      Builds this column's catalog entry: key and label plus the display (render, href, className, defaultVisible) and search (searchType, searchOperators, customOperators) metadata, flattened onto one entry, in the form the datatables card type resolves.

      searchOperators is a list of operator names and customOperators a list of {name,help} maps for the custom ones. Both are emitted only when this column has its own operator set; a column inheriting the table-level set emits just searchType, and a column with no search type emits neither. See toCatalogMap(SearchOperatorSet) to resolve the table-level set into the entry.

      label falls back to name() when unset. A column with an href and no render emits render as the linked renderer.

      Returns:
      The catalog entry.
    • toCatalogMap

      public JsonMap toCatalogMap(SearchOperatorSet tableDefault)
      Builds this column's catalog entry like toCatalogMap(), but emits the column's effective operator set: its own set if it has one, else tableDefault.

      This is how a table-level set reaches the datatables card type, which reads operators per column. With no column set and a null tableDefault, only searchType is emitted.

      Parameters:
      tableDefault - The table-level operator set inherited by a column with none of its own. Can be null.
      Returns:
      The catalog entry.
    • name

      public String name()
      Returns:
      The column name.
    • label

      public String label()
      Returns:
      The column label, or null.
    • searchType

      Returns:
      The column value type, or null if the column is not searchable.
    • operators

      This column's own operator set, or null if absent (inherit the table-level set).
      Returns:
      The operator set, or null.
    • searchable

      public boolean searchable()
      Returns:
      true if this column has a search type (and is therefore searchable).
    • effectiveOperators

      Resolves the effective operator set the header popup offers for this column, against the built-in standard set as the fallback default.
      Returns:
      The effective operators, in the resolved set's order; empty when the column is not searchable.
    • effectiveOperators

      Resolves the effective operator set the header popup offers for this column, inheriting the specified table-level set when this column has none of its own.
      Parameters:
      tableDefault - The table-level operator set to inherit when this column has none of its own. Can be null, in which case SearchOperatorSet.standard() is used.
      Returns:
      The effective operators, in the resolved set's order; empty when the column is not searchable.
    • offers

      public boolean offers(String opName)
      Whether the named operator is on this column's effective set — i.e. whether the popup offers it (and accepts it rather than rejecting it as invalid).
      Parameters:
      opName - The operator name, including the leading $. Can be null.
      Returns:
      true if the operator is offered for this column.
    • searchMeta

      public static JsonMap searchMeta(String name, String searchTypeWire, List<String> operatorAllowList, List<Map<String,String>> customOperators)
      Builds the per-column search block for the VIEW_META wire contract directly from author-catalog inputs, without the caller having to touch the search-engine beans.

      This is the entry point the chrome/authoring layer uses: it takes only the wire token, the optional allowed-operator names, and the custom operators as plain {name,help} maps — so a chrome-only module that must not depend on the search engine can still emit a column's search block by calling here. Internally this builds a single SearchOperatorSet: an allow-list becomes SearchOperatorSet.of(SearchOperator...) with exactly the named operators (customs preferred over same-named built-ins), while an absent allow-list becomes SearchOperatorSet.standard() with each custom appended via SearchOperatorSet.with(SearchOperator).

      Parameters:
      name - The column name (row-data key). Must not be null or blank.
      searchTypeWire - The wire SearchType token, or null.
      operatorAllowList - The explicit allowed-operator names, or null for the default (the full type-applicable universe).
      customOperators - Per-column custom operators as {name,help} maps; may be null or empty.
      Returns:
      The {type, operators:[...]} block, or null when searchTypeWire names no known type (a non-searchable column emits no search block).
    • searchMeta

      public JsonMap searchMeta()
      Serializes this column's effective search configuration to the VIEW_META search block: the wire SearchType token plus one entry per effective operator, each carrying the metadata the header popup renders.

      help is present only for custom operators; the popup supplies built-in help text from juneau-search.js.

      Returns:
      The {type, operators:[{name,help,minArgs,maxArgs,combinator,custom}]} block, or null if this column is not searchable.
    • searchMeta

      public JsonMap searchMeta(SearchOperatorSet tableDefault)
      Serializes this column's effective search configuration to the VIEW_META search block, inheriting the specified table-level operator set when this column has none of its own.
      Parameters:
      tableDefault - The table-level operator set to inherit when this column has none of its own. Can be null, in which case SearchOperatorSet.standard() is used.
      Returns:
      The {type, operators:[{name,help,minArgs,maxArgs,combinator,custom}]} block, or null if this column is not searchable.