Class FilterTransformer

java.lang.Object
com.vaadin.hilla.crud.filter.FilterTransformer

public class FilterTransformer extends Object
Utility class for transforming property names in filters and pageable objects.
  • Constructor Details

    • FilterTransformer

      public FilterTransformer()
  • Method Details

    • withMapping

      public FilterTransformer withMapping(String from, String to)
      Declares a mapping from one property name to another. If a filter or pageable is transformed, all occurrences of the property name will be replaced with the new name.
      Parameters:
      from - The original property name.
      to - The new property name.
      Returns:
      This instance.
    • withFilterTransformation

      public FilterTransformer withFilterTransformation(Function<PropertyStringFilter,PropertyStringFilter> filterTransformation)
      Declares a function that will be applied to all PropertyStringFilter instances, allowing any kind of customization, including a replacement of the filter itself. This can be used to modify the filter value in a more complex way than a simple mapping.

      Note: The passed in filterTransformation function is applied after all other mappings are applied.

      Parameters:
      filterTransformation - The function to apply.
      Returns:
      This instance.
    • apply

      public Filter apply(Filter filter)
      Applies registered property mappings and transformation function on the provided filter instance.
      Parameters:
      filter - The filter instance to transform.
      Returns:
      The transformed filter.
    • apply

      public org.springframework.data.domain.Pageable apply(org.springframework.data.domain.Pageable pageable)
      Applies registered property mappings on the provided pageable instance.

      Note: The passed in filterTransformation function is not applied on pageables.

      Parameters:
      pageable - The pageable instance to transform.
      Returns:
      The transformed pageable.