Class ModelHelper

    • Method Detail

      • hasModelItem

        public static boolean hasModelItem​(String path,
                                           Collection<? extends ModelItemAccessor> itemAccessors)
                                    throws IllegalArgumentException
        Checks if there is a model item at the given relative path
        Parameters:
        path - path of the model item. This path is relative to the given accessors. No matter if it is a definition or data path (with repeater entry positions)
        itemAccessors - model item accessors where to search if there is a model item
        Returns:
        true if there is model item at this path, false otherwise
        Throws:
        IllegalArgumentException - if the given path is null or empty
      • hasModelItemOfType

        public static boolean hasModelItemOfType​(ModelItemContainer container,
                                                 String type)
        Determines if a container of model items contains a model item of the given type
        Parameters:
        container - the model item container
        type - the type identifier to find.
        Returns:
        true if a model item of the given type is found
      • getDefinitionPathFromDataPath

        public static String getDefinitionPathFromDataPath​(String dataPath)
        Retrieves the given dataPath as a definition path (without the repeaterEntry positions)
        Parameters:
        dataPath - the data path
        Returns:
        the definition path
      • isGroupSwitchOn

        public static boolean isGroupSwitchOn​(ModelItem modelItem,
                                              Map<String,​Object> values)
        Checks if this item is in a group with a switch on
        Parameters:
        modelItem - the item to check
        values - all items' values to get switchers' values
        Returns:
        false if this item is part of a group with a switch to off, true otherwise
      • evaluateDisableConditions

        public static boolean evaluateDisableConditions​(DisableConditions disableConditions,
                                                        Map<String,​DefinitionAndValue> definitionAndValues,
                                                        org.slf4j.Logger logger)
        Recursively evaluate the DisableConditions against the given values
        Parameters:
        disableConditions - the disable conditions to evaluate
        definitionAndValues - the values to evaluate
        logger - the logger for disable conditions evaluation logs
        Returns:
        true if the disable conditions are true, false otherwise
      • validateValue

        public static List<I18nizableTextvalidateValue​(ElementDefinition definition,
                                                         Object value)
        Validates the given value
        Parameters:
        definition - The definition to use to validate the value
        value - the value to validate
        Returns:
        the structure with errors information if the validation failed.
      • validateValue

        public static List<I18nizableTextvalidateValue​(ElementDefinition definition,
                                                         Object value,
                                                         boolean checkEnumerated)
        Validates the given value
        Parameters:
        definition - The definition to use to validate the value
        value - the value to validate
        checkEnumerated - true true to make sure that the item with an enumerator has its value in the enumerated values
        Returns:
        the structure with errors information if the validation failed. TODO NEWATTRIBUTEAPI RUNTIME-2897: remove this method to always check enumerator when validating a value