Class ModelUtils


  • public class ModelUtils
    extends Object
    Static utility methods to work with model.
    • Constructor Detail

      • ModelUtils

        public ModelUtils()
    • Method Detail

      • newEventHandler

        public static EventHandler newEventHandler​(String name,
                                                   Event event)
        Creates and returns the new form event handler with the provided handler name.
        Parameters:
        name - the name of the form event handler, cannot be null
        event - the event to create handler for, cannot be null
        Returns:
        the new form event handler with the provided name, never null
      • newEventHandler

        public static EventHandlerExtension newEventHandler​(String name,
                                                            Event event,
                                                            ExtendedMethodCallType callType)
        Creates and returns the new form extension event handler with the provided handler name and method call type.
        Parameters:
        name - the name of the form event handler, cannot be null
        event - the event to create handler for, cannot be null
        callType - the method call type, cannot be null
        Returns:
        the new form event whandler ith the provided name and method call type, never null
      • findEventHanlder

        public static Optional<EventHandler> findEventHanlder​(String eventName,
                                                              Collection<EventHandler> handlers)
        Finds and returns a handler for the provided event english name in the provided handler collection. If there are more than one handler for the provided event then result will be unpredictable.
        Parameters:
        eventName - the event english name to find handler for, cannot be null
        handlers - the handler collection to find in, cannot be null
        Returns:
        a handler for the provided event in the provided handler collection, never null
      • findEventHanlder

        public static Optional<EventHandler> findEventHanlder​(Event event,
                                                              Collection<EventHandler> handlers)
        Finds and returns a handler for the provided event in the provided handler collection. If there are more than one handler for the provided event then result will be unpredictable.
        Parameters:
        event - the event to find handler for, cannot be null
        handlers - the handler collection to find in, cannot be null
        Returns:
        a handler for the provided event in the provided handler collection, never null
      • findEventHanlder

        public static Optional<EventHandler> findEventHanlder​(String eventName,
                                                              ExtendedMethodCallType callType,
                                                              Collection<EventHandler> handlers)
        Finds and returns a handler for the provided event in the provided handler collection. If there are more than one handler for the provided event and call type then result will be unpredictable.
        Parameters:
        eventName - the event english name to find handler for, cannot be null
        callType - the method call type, cannot be null
        handlers - the handler collection to find in, cannot be null
        Returns:
        a handler for the provided event in the provided handler collection, never null
      • addEventHandler

        public static void addEventHandler​(EventHandler handler,
                                           List<EventHandler> handlers)
        Adds the provided possibly new handler to the handler collection with respect to existing handlers with the same evet: if handlers collection already contains handler for the same event, it will be replaced with the provided handler.
        Parameters:
        handler - the handler to add, cannot be null
        handlers - the collection to add to, cannot be null
      • setCommandHandler

        public static void setCommandHandler​(FormCommand command,
                                             String handlerName)
        Sets the new form command handler with the provided handler name.
        Parameters:
        command - the form command to set handler for, cannot be null
        handlerName - the name of the form command handler, cannot be null
      • getCommandHandlers

        public static List<CommandHandler> getCommandHandlers​(FormCommand command)
        Returns the command handler collection for the provided command.
        Parameters:
        command - the form command to get handler collection for, cannot be null
        Returns:
        the command handler collection for the provided command, never null
      • findCommandHandler

        public static Optional<CommandHandlerExtension> findCommandHandler​(FormCommand command,
                                                                           ExtendedMethodCallType callType)
        Finds and returns a handler for the provided form command with the provided call type. If there are more than one handler for the provided command and call type then result will be unpredictable.
        Parameters:
        command - the form command to find handler for, cannot be null
        callType - the method call type, cannot be null
        Returns:
        a handler for the provided command with the provided call type, never null
      • addCommandHandler

        public static void addCommandHandler​(FormCommand command,
                                             String handlerName,
                                             ExtendedMethodCallType callType)
        Adds a command handler to the provided form command.
        Parameters:
        command - the form command to add handler for, cannot be null
        handlerName - the handler name to add, cannot be null
        callType - the method call type, cannot be null
      • getFormItemChildItems

        public static List<FormItem> getFormItemChildItems​(FormVisualEntity parent)
        Gets the list of the children FormItem. Is defined for Group, Table, MainItem; Empty list otherwise.
        Parameters:
        parent - a parent FormItem
        Returns:
        a list of the children FormItem.
      • getMdCommandGroups

        public static Collection<CommandGroup> getMdCommandGroups​(Configuration configuration,
                                                                  CommandGroupCategory category)
        Filters the configuration command groups using category.
        Parameters:
        configuration - - a command groups provider
        category - - a filter
        Returns:
        a filtered command groups collection