Class MetadataBasedGroupingProvider
java.lang.Object
org.vaadin.miki.superfields.object.util.MetadataBasedGroupingProvider
- All Implemented Interfaces:
Serializable,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 Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns name of the metadata property used to obtain group names.Returns the current name of the metadata property used for sorting.groupDefinitions(List<Property<T, ?>> definitions) Groups given definitions.voidsetGroupingMetadataName(String groupingMetadataName) Sets the name of the metadata property used to obtain group names.voidsetSortingMetadataName(String sortingMetadataName) Sets the name of the metadata property used for sorting the properties.withGroupingMetadataName(String metadataName) ChainssetGroupingMetadataName(String)and returns itself.withSortingMetadataName(String metadataName) ChainssetSortingMetadataName(String)and returns itself.
-
Field Details
-
ACCEPTED_SORTING_METADATA_TYPES
-
ACCEPTED_GROUPING_METADATA_TYPE
-
-
Constructor Details
-
MetadataBasedGroupingProvider
public MetadataBasedGroupingProvider()
-
-
Method Details
-
groupDefinitions
Description copied from interface:PropertyGroupingProviderGroups given definitions.- Specified by:
groupDefinitionsin interfacePropertyGroupingProvider- Type Parameters:
T- Type parameter forPropertys.- Parameters:
definitions- Definitions to group.- Returns:
- A non-
null(but possibly empty) map. The map will not contain newPropertys, those from the parameter will be reused.
-
getGroupingMetadataName
Returns name of the metadata property used to obtain group names.- Returns:
- Name of the metadata property. May be
nullwhen no metadata property was specified.
-
setGroupingMetadataName
Sets the name of the metadata property used to obtain group names. May be set tonulldo disable grouping. In such case eachPropertywill be in its own, single element group, regardless of the metadata.- Parameters:
groupingMetadataName- Name of the metadata. Its type must beACCEPTED_GROUPING_METADATA_TYPE.
-
withGroupingMetadataName
ChainssetGroupingMetadataName(String)and returns itself.- Parameters:
metadataName- Name of the metadata.- Returns:
- This.
- See Also:
-
getSortingMetadataName
Returns the current name of the metadata property used for sorting.- Returns:
- Metadata name. May be
null.
-
setSortingMetadataName
Sets the name of the metadata property used for sorting the properties. May be set tonullto disable sorting.- Parameters:
sortingMetadataName- Name of the metadata. Its type must belong toACCEPTED_SORTING_METADATA_TYPES.
-
withSortingMetadataName
ChainssetSortingMetadataName(String)and returns itself.- Parameters:
metadataName- Metadata name.- Returns:
- This.
- See Also:
-