Package org.ametys.runtime.model
Class CategorizedElementDefinitionHelper
java.lang.Object
org.ametys.runtime.model.CategorizedElementDefinitionHelper
Helper for
CategorizedElementDefinitionWrapper-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends CategorizedElementDefinitionWrapper>
ViewbuildViewFromCategories(Collection<T> wrappers, Comparator<I18nizableText> categoriesComparator, Comparator<I18nizableText> groupsComparator, Comparator<T> elementsComparator) Generate the view for categorized element definition wrappers, using comparators to sort the categories, groups and elementsstatic <T extends CategorizedElementDefinitionWrapper>
Map<I18nizableText, Map<I18nizableText, List<T>>> categorizeElementDefinitionWrappers(Collection<T> wrappers) Organize a collection of categorized element definition wrappers by categories and groups.static intcomparePositions(Long position1, Long position2) Compares the two given position.static <T extends CategorizedElementDefinitionWrapper>
intcompareWrapperPositions(T wrapper1, T wrapper2) Compares the two given wrappers' position.static <T> Collection<T> sortItemsList(Collection<T> items, Comparator<T> comparator) Sort a model item list using comparatorstatic ValidationResultsvalidateValuesForWriting(Map<String, Object> values, Collection<? extends ElementDefinition> definitions, DisableConditionsEvaluator disableConditionsEvaluator, org.slf4j.Logger logger) Validate parameters before writing
-
Method Details
-
buildViewFromCategories
public static <T extends CategorizedElementDefinitionWrapper> View buildViewFromCategories(Collection<T> wrappers, Comparator<I18nizableText> categoriesComparator, Comparator<I18nizableText> groupsComparator, Comparator<T> elementsComparator) Generate the view for categorized element definition wrappers, using comparators to sort the categories, groups and elements- Type Parameters:
T- type of the wrappers- Parameters:
wrappers- the wrapperscategoriesComparator-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
-
categorizeElementDefinitionWrappers
public static <T extends CategorizedElementDefinitionWrapper> Map<I18nizableText,Map<I18nizableText, categorizeElementDefinitionWrappersList<T>>> (Collection<T> wrappers) Organize a collection of categorized element definition wrappers by categories and groups.- Type Parameters:
T- type of the wrappers- Parameters:
wrappers- a collection of element definition wrappers.- Returns:
- a Map with the same element definition wrappers, sorted first by category then by group.
-
sortItemsList
Sort a model item list using comparator- Type Parameters:
T- The type of item to compare- 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)
-
validateValuesForWriting
public static ValidationResults validateValuesForWriting(Map<String, Object> values, Collection<? extends ElementDefinition> definitions, DisableConditionsEvaluator disableConditionsEvaluator, org.slf4j.Logger logger) Validate parameters before writing- Parameters:
values- a map of all parameters and their valuesdefinitions- collection ofElementDefinitionfrom the model filedisableConditionsEvaluator- the disable conditions evaluator for the given objectlogger- a logger- Returns:
- a map containing the potential errors
-
compareWrapperPositions
public static <T extends CategorizedElementDefinitionWrapper> int compareWrapperPositions(T wrapper1, T wrapper2) Compares the two given wrappers' position. Returns a negative integer, zero, or a positive integer as the position of the first wrapper is less than, equal to, or greater than the second.- Type Parameters:
T- type of the wrappers to compare- Parameters:
wrapper1- the first wrapperwrapper2- the second wrapper- Returns:
- a negative integer, zero, or a positive integer as the position of the first wrapper is less than, equal to, or greater than the second.
-
comparePositions
Compares the two given position. Returns a negative integer, zero, or a positive integer as the first position is less than, equal to, or greater than the second.- Parameters:
position1- the first positionposition2- the second position- Returns:
- a negative integer, zero, or a positive integer as the first position is less than, equal to, or greater than the second.
-