Class CategorizedElementDefinitionHelper

java.lang.Object
org.ametys.runtime.model.CategorizedElementDefinitionHelper

public final class CategorizedElementDefinitionHelper extends Object
  • 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 wrappers
      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 the ModelItem using the Comparator
    • categorizeElementDefinitionWrappers

      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.
    • validateValuesForWriting

      public static <T> ValidationResults validateValuesForWriting(Map<String,Object> values, Collection<ElementDefinition> definitions, DisableConditionsEvaluator<T> disableConditionsEvaluator, Logger logger)
      Validate parameters before writing
      Type Parameters:
      T - Type of object containing the values
      Parameters:
      values - a map of all parameters and their values
      definitions - collection of ElementDefinition from the model file
      disableConditionsEvaluator - the disable conditions evaluator for the given object
      logger - 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 wrapper
      wrapper2 - 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.