Package com.vaadin.hilla.crud.filter
Class FilterTransformer
java.lang.Object
com.vaadin.hilla.crud.filter.FilterTransformer
Utility class for transforming property names in filters and pageable
objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionApplies registered property mappings and transformation function on the provided filter instance.org.springframework.data.domain.Pageableapply(org.springframework.data.domain.Pageable pageable) Applies registered property mappings on the provided pageable instance.withFilterTransformation(Function<PropertyStringFilter, PropertyStringFilter> filterTransformation) Declares a function that will be applied to allPropertyStringFilterinstances, allowing any kind of customization, including a replacement of the filter itself.withMapping(String from, String to) Declares a mapping from one property name to another.
-
Constructor Details
-
FilterTransformer
public FilterTransformer()
-
-
Method Details
-
withMapping
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 allPropertyStringFilterinstances, 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
filterTransformationfunction is applied after all other mappings are applied.- Parameters:
filterTransformation- The function to apply.- Returns:
- This instance.
-
apply
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
filterTransformationfunction is not applied on pageables.- Parameters:
pageable- The pageable instance to transform.- Returns:
- The transformed pageable.
-