Class ModelItemGroup

java.lang.Object
org.ametys.runtime.model.AbstractModelItem
org.ametys.runtime.model.ModelItemGroup
All Implemented Interfaces:
Comparable<ModelItem>, ModelItem, ModelItemAccessor, ModelItemContainer, Labelable, ModifiableLabelable
Direct Known Subclasses:
CompositeDefinition, RepeaterDefinition

public class ModelItemGroup extends AbstractModelItem implements ModelItemContainer
Class for group of model items
  • Field Details

  • Constructor Details

    • ModelItemGroup

      public ModelItemGroup()
      Default constructor.
    • ModelItemGroup

      public ModelItemGroup(String name, ModelItem... children)
      Constructor used to create simple models and items
      Parameters:
      name - the name of the definition
      children - the group's children
  • Method Details

    • getModelItems

      Description copied from interface: ModelItemAccessor
      Retrieves all the model items of this accessor
      Specified by:
      getModelItems in interface ModelItemAccessor
      Returns:
      the model items
    • getChildren

      Retrieves the list of children model items
      Returns:
      the children
    • getChildren

      public List<ModelItem> getChildren(boolean withSwitch)
      Retrieves the list of children model items, with or without the switcher
      Parameters:
      withSwitch - true to retrieve the switcher with the other children
      Returns:
      the children with or without the switcher
    • addChild

      public void addChild(ModelItem child)
      Add a child in the group
      Parameters:
      child - the item to add
    • addChild

      public void addChild(ModelItem child, boolean isGroupSwitch)
      Add a child in the group
      Parameters:
      child - the child to add
      isGroupSwitch - true if the child to add is the group switch, false otherwise
    • getSwitcher

      Retrieves the switcher element definition
      Returns:
      the switcher
    • setModel

      public void setModel(Model model)
      Description copied from interface: ModelItem
      Sets the model of the element
      Specified by:
      setModel in interface ModelItem
      Overrides:
      setModel in class AbstractModelItem
      Parameters:
      model - the model to set
    • getType

      Description copied from interface: ModelItem
      Retrieves the type.
      Specified by:
      getType in interface ModelItem
      Returns:
      the type.
    • setType

      public void setType(ModelItemType type)
      Description copied from interface: ModelItem
      Set the type.
      Specified by:
      setType in interface ModelItem
      Parameters:
      type - the type.
    • _toJSON

      protected Map<String,Object> _toJSON(DefinitionContext context)
      Description copied from class: AbstractModelItem
      Converts the model item in a JSON map
      Overrides:
      _toJSON in class AbstractModelItem
      Parameters:
      context - the context of the definition
      Returns:
      The model item as a JSON map
    • toJSON

      public Map<String,Object> toJSON(DefinitionContext context, boolean includeChildren)
      Converts the model item group in a JSON map
      Parameters:
      context - the context of the definition
      includeChildren - true to iterate and add children as elements in the returned JSON map, false otherwise
      Returns:
      The model item as a JSON map
    • _toJSON

      protected Map<String,Object> _toJSON(DefinitionContext context, boolean includeChildren)
      Converts the model item group in a JSON map
      Parameters:
      context - the context of the definition
      includeChildren - true to iterate and add children as elements in the returned JSON map, false otherwise
      Returns:
      The model item as a JSON map
    • toSAX

      public void toSAX(ContentHandler contentHandler, DefinitionContext context) throws SAXException
      Generates SAX events for the model item Do not generate SAX events for children. This method has been created to generate SAX events for views, the children are taken into account via view items children
      Specified by:
      toSAX in interface ModelItem
      Overrides:
      toSAX in class AbstractModelItem
      Parameters:
      contentHandler - the ContentHandler that will receive the SAX events
      context - the context of the definition
      Throws:
      SAXException - if an error occurs during the SAX events generation
    • of

      public static ModelItemGroup of(String name, ModelItem... children)
      Creates a ModelItemGroup
      Parameters:
      name - the group's name
      children - the group's children
      Returns:
      the created ModelItemGroup