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 privateConfigParameterDefinitionHelper()
-
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 ViewbuildConfigParametersView(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 anIllegalArgumentExceptionwill be thrown if the hierarchy is incorrect.static List<ModelItem>categorizeConfigParameters(Collection<ConfigParameterDefinitionWrapper> elements)Categorize the ModlItems based on the informations in theCategorizedElementDefinitionWrappercollection 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 thisCategorizedElementDefinitionWrapperCollection, 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 thisCategorizedElementDefinitionWrapperCollection, as a flat map.- Parameters:
elements- aCollectionofCategorizedElementDefinitionWrapper- 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 theCategorizedElementDefinitionWrappercollection 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
ModelItemwith 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 anIllegalArgumentExceptionwill be thrown if the hierarchy is incorrect.- Parameters:
categories- list ofModelItemcategoriesComparator-Comparatorused for the categories (can be null to keep order)groupsComparator-Comparatorfor the groups (can be null to keep order)elementsComparator-Comparatorfor the elements (can be null to keep order)- Returns:
- A
Viewordered from theModelItemusing 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)
-
-