Package org.ametys.runtime.config
Class ConfigParameterDefinitionHelper
- java.lang.Object
-
- org.ametys.runtime.config.ConfigParameterDefinitionHelper
-
public final class ConfigParameterDefinitionHelper extends Object
Helper forConfigParameterDefinitionWrapper
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ConfigParameterDefinitionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static ModelViewItemGroup
_buildCategoryViewItem(ModelItem modelItem, Comparator<? super ModelItem> groupsComparator, Comparator<? super ModelItem> elementsComparator)
private static ModelViewItem
_buildElementViewItem(ModelItem modelItem)
private static ModelViewItemGroup
_buildGroupViewItem(ModelItem modelItem, Comparator<? super ModelItem> elementsComparator)
private static Collection<? extends ModelItem>
_sort(Collection<? extends ModelItem> items, Comparator<? super ModelItem> comparator)
sort a model item list using comparatorstatic View
buildConfigParametersView(Collection<? extends ModelItem> categories, Comparator<? super ModelItem> categoriesComparator, Comparator<? super ModelItem> groupsComparator, Comparator<? super ModelItem> elementsComparator)
Generate the view for a list ofModelItem
, using comparators to sort the categories and the groups This works only on the very specific categories/group/fieldset hierarchy and anIllegalArgumentException
will be thrown if the hierarchy is incorrect.static List<ModelItem>
categorizeConfigParameters(Collection<ConfigParameterDefinitionWrapper> elements)
Categorize the ModlItems based on the informations in theCategorizedElementDefinitionWrapper
collection Category and groups are not sorted, only definitions, based on the position.static Map<String,ElementDefinition>
getFlatDefinitions(Collection<ConfigParameterDefinitionWrapper> elements)
Get definitions of all elements parsed in thisCategorizedElementDefinitionWrapper
Collection
, as a flat map.
-
-
-
Constructor Detail
-
ConfigParameterDefinitionHelper
private ConfigParameterDefinitionHelper()
-
-
Method Detail
-
getFlatDefinitions
public static Map<String,ElementDefinition> getFlatDefinitions(Collection<ConfigParameterDefinitionWrapper> elements)
Get definitions of all elements parsed in thisCategorizedElementDefinitionWrapper
Collection
, as a flat map.- Parameters:
elements
- aCollection
ofCategorizedElementDefinitionWrapper
- Returns:
- a map with the definition name as key, containing all definitions
-
categorizeConfigParameters
public static List<ModelItem> categorizeConfigParameters(Collection<ConfigParameterDefinitionWrapper> elements)
Categorize the ModlItems based on the informations in theCategorizedElementDefinitionWrapper
collection Category and groups are not sorted, only definitions, based on the position. Sorting of category and groups have to be done when the view is created (each usage can be different)- Parameters:
elements
- collection of categorized elements- Returns:
- a list of
ModelItem
with the correct tree (category/group/definitions)
-
buildConfigParametersView
public static View buildConfigParametersView(Collection<? extends ModelItem> categories, Comparator<? super ModelItem> categoriesComparator, Comparator<? super ModelItem> groupsComparator, Comparator<? super ModelItem> elementsComparator) throws IllegalArgumentException
Generate the view for a list ofModelItem
, using comparators to sort the categories and the groups This works only on the very specific categories/group/fieldset hierarchy and anIllegalArgumentException
will be thrown if the hierarchy is incorrect.- Parameters:
categories
- list ofModelItem
categoriesComparator
-Comparator
used for the categories (can be null to keep order)groupsComparator
-Comparator
for the groups (can be null to keep order)elementsComparator
-Comparator
for the elements (can be null to keep order)- Returns:
- A
View
ordered from theModelItem
using theComparator
- Throws:
IllegalArgumentException
- the hierarchy of the categories/groups/elements is incorrect
-
_buildCategoryViewItem
private static ModelViewItemGroup _buildCategoryViewItem(ModelItem modelItem, Comparator<? super ModelItem> groupsComparator, Comparator<? super ModelItem> elementsComparator) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
_buildGroupViewItem
private static ModelViewItemGroup _buildGroupViewItem(ModelItem modelItem, Comparator<? super ModelItem> elementsComparator) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
_buildElementViewItem
private static ModelViewItem _buildElementViewItem(ModelItem modelItem) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
_sort
private static Collection<? extends ModelItem> _sort(Collection<? extends ModelItem> items, Comparator<? super ModelItem> comparator)
sort a model item list using comparator- Parameters:
items
- list of items to sortcomparator
- a comparator, can be null to avoid sort- Returns:
- a sorted list (or a copy of the list if the comparator is null)
-
-