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 aStringmetadata property. Can optionally also sort, based on anotherIntegermetadata property. Grouping metadata must be of typeACCEPTED_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 toACCEPTED_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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Class<String>ACCEPTED_GROUPING_METADATA_TYPEstatic Set<Class<?>>ACCEPTED_SORTING_METADATA_TYPES
-
Constructor Summary
Constructors Constructor Description MetadataBasedGroupingProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetGroupingMetadataName()Returns name of the metadata property used to obtain group names.StringgetSortingMetadataName()Returns the current name of the metadata property used for sorting.<T> Map<String,List<Property<T,?>>>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.MetadataBasedGroupingProviderwithGroupingMetadataName(String metadataName)ChainssetGroupingMetadataName(String)and returns itself.MetadataBasedGroupingProviderwithSortingMetadataName(String metadataName)ChainssetSortingMetadataName(String)and returns itself.
-
-
-
Method Detail
-
groupDefinitions
public <T> Map<String,List<Property<T,?>>> groupDefinitions(List<Property<T,?>> definitions)
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
public String 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
public void setGroupingMetadataName(String groupingMetadataName)
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
public final MetadataBasedGroupingProvider withGroupingMetadataName(String metadataName)
ChainssetGroupingMetadataName(String)and returns itself.- Parameters:
metadataName- Name of the metadata.- Returns:
- This.
- See Also:
setGroupingMetadataName(String)
-
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 tonullto disable sorting.- Parameters:
sortingMetadataName- Name of the metadata. Its type must belong toACCEPTED_SORTING_METADATA_TYPES.
-
withSortingMetadataName
public final MetadataBasedGroupingProvider withSortingMetadataName(String metadataName)
ChainssetSortingMetadataName(String)and returns itself.- Parameters:
metadataName- Metadata name.- Returns:
- This.
- See Also:
setSortingMetadataName(String)
-
-