Class MetadataBasedGroupingProvider

java.lang.Object
org.vaadin.miki.superfields.object.util.MetadataBasedGroupingProvider
All Implemented Interfaces:
Serializable, PropertyGroupingProvider

public class MetadataBasedGroupingProvider extends Object implements PropertyGroupingProvider
A grouping provider based on a String metadata property. Can optionally also sort, based on another Integer metadata property. Grouping metadata must be of type ACCEPTED_GROUPING_METADATA_TYPE. When the group name is not specified, a single-element group with the property is created, with the name of that property as the name of the group. Sorting metadata must be of type that belongs to ACCEPTED_SORTING_METADATA_TYPES. Sorting is done by value of the metadata first, then by name of the property.
Since:
2022-09-02
Author:
miki
See Also:
  • Field Details

    • ACCEPTED_SORTING_METADATA_TYPES

      public static final Set<Class<?>> ACCEPTED_SORTING_METADATA_TYPES
    • ACCEPTED_GROUPING_METADATA_TYPE

      public static final Class<String> ACCEPTED_GROUPING_METADATA_TYPE
  • Constructor Details

    • MetadataBasedGroupingProvider

      public MetadataBasedGroupingProvider()
  • Method Details

    • groupDefinitions

      public <T> Map<String,List<Property<T,?>>> groupDefinitions(List<Property<T,?>> definitions)
      Description copied from interface: PropertyGroupingProvider
      Groups given definitions.
      Specified by:
      groupDefinitions in interface PropertyGroupingProvider
      Type Parameters:
      T - Type parameter for Propertys.
      Parameters:
      definitions - Definitions to group.
      Returns:
      A non-null (but possibly empty) map. The map will not contain new Propertys, those from the parameter will be reused.
    • getGroupingMetadataName

      public String getGroupingMetadataName()
      Returns name of the metadata property used to obtain group names.
      Returns:
      Name of the metadata property. May be null when no metadata property was specified.
    • setGroupingMetadataName

      public void setGroupingMetadataName(String groupingMetadataName)
      Sets the name of the metadata property used to obtain group names. May be set to null do disable grouping. In such case each Property will be in its own, single element group, regardless of the metadata.
      Parameters:
      groupingMetadataName - Name of the metadata. Its type must be ACCEPTED_GROUPING_METADATA_TYPE.
    • withGroupingMetadataName

      public final MetadataBasedGroupingProvider withGroupingMetadataName(String metadataName)
      Chains setGroupingMetadataName(String) and returns itself.
      Parameters:
      metadataName - Name of the metadata.
      Returns:
      This.
      See Also:
    • getSortingMetadataName

      public String getSortingMetadataName()
      Returns the current name of the metadata property used for sorting.
      Returns:
      Metadata name. May be null.
    • setSortingMetadataName

      public void setSortingMetadataName(String sortingMetadataName)
      Sets the name of the metadata property used for sorting the properties. May be set to null to disable sorting.
      Parameters:
      sortingMetadataName - Name of the metadata. Its type must belong to ACCEPTED_SORTING_METADATA_TYPES.
    • withSortingMetadataName

      public final MetadataBasedGroupingProvider withSortingMetadataName(String metadataName)
      Chains setSortingMetadataName(String) and returns itself.
      Parameters:
      metadataName - Metadata name.
      Returns:
      This.
      See Also: