/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { SearchSortField } from "../../types/senselogic/sitevision/api/search/SearchSortField"; import type { Sort } from "../../types/senselogic/sitevision/api/search/searcher/component/Sort"; import type { Builder } from "../../types/senselogic/sitevision/api/base/Builder"; /** *

* Builder for creating a {@link senselogic.sitevision.api.search.searcher.component.Sort} component with specific behaviour. *

* *

* SortBuilder has one mandatory attribute: *

* * *

* Using the SortBuilder is pretty straightforward, if you remember that it is stateful. Conceptually you * would typically use it like this: *

*
    *
  1. Get the SortBuilder
  2. *
  3. Create a SearchSortField
  4. *
  5. Add the SearchSortField to the SortBuilder
  6. *
  7. Possibly create another SearchSortField and add it to the SortBuilder
  8. *
  9. Do build
  10. *
*

* When you have built a Sort instance, you can re-use the SortBuilder to build more instances. Typically like: *

*
    *
  1. Clear the sort fields
  2. *
  3. Create a SearchSortField and add it to the SortBuilder
  4. *
  5. Possibly create another SearchSortField and add it to the SortBuilder
  6. *
  7. Do build
  8. *
* *

* Example of how this strategy could be implemented in sever-side Javascript: *

*
   // Get the factory and the builder
 *    var searchFactory = require('SearchFactory'),
 *        sortBuilder = searchFactory.getSortBuilder(),
 *        searchSortField,
 *        updatedDescSort,
 *        nameAscSort;
 *
 *    // Create a Sort
 *    searchSortField = searchFactory.getSearchSortField('lastpublished', false);
 *    updatedDescSort = sortBuilder.addSortField(searchSortField).build();
 *
 *    // Re-use the builder to create another Sort
 *    searchSortField = searchFactory.getSearchSortField('name.sortable', true);
 *    nameAscSort = sortBuilder.clearSortFields().addSortField(searchSortField).build();
 *  
* *

* Example of how this strategy could be implemented in Velocity: *

*
   ## Get the factory and the builder
 *    #set ($searchFactory = $sitevisionUtils.searchFactory)
 *    #set ($sortBuilder = $searchFactory.sortBuilder)
 *
 *    ## Create a Sort
 *    #set ($searchSortField = $searchFactory.getSearchSortField('lastpublished', false))
 *    #set ($updatedDescSort = $sortBuilder.addSortField($searchSortField).build())
 *
 *    ## Re-use the builder to create another Sort
 *    #set ($searchSortField = $searchFactory.getSearchSortField('name.sortable', true))
 *    #set ($nameAscSort = $sortBuilder.clearSortFields().addSortField($searchSortField).build())
 *  
* *

* Tip! The {@link senselogic.sitevision.api.base.Builder Builder interface documentation} contains * more information about Builders and how to work with them! *

* *

* An instance of the Sitevision class implementing this interface can be obtained via * {@link senselogic.sitevision.api.search.SearchFactory#getSortBuilder()}. * See {@link senselogic.sitevision.api.search.SearchFactory} for how to obtain an instance of the SearchFactory interface. *

* @author Magnus Lövgren * @since Sitevision 3.6 */ export interface SortBuilder extends Builder { /** * Adds a sort field. * @param aSearchSortField a sort field, a null value is ignored * @return this builder */ addSortField(aSearchSortField: SearchSortField): SortBuilder; /** * Removes all previously added sort fields. * @return this builder */ clearSortFields(): SortBuilder; /** * Creates a Sort component instance using currently specified state/behaviour. * @return a Sort component * @throws IllegalStateException if no sort fields are added */ build(): Sort; } declare namespace SortBuilder {} declare var sortBuilder: SortBuilder; export default sortBuilder;