Class BaseNodeItemContainer<I extends io.github.mmm.code.api.item.CodeItem>

Type Parameters:
I - the type of the contained CodeItem.
All Implemented Interfaces:
io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeContainer<I>, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.node.CodeNodeItemContainer<I>, io.github.mmm.code.api.object.CodeMutable, Iterable<I>
Direct Known Subclasses:
BaseMembers, BaseNodeItemContainerFlat, BaseNodeItemContainerHierarchical, BaseNodeItemContainerWithName

public abstract class BaseNodeItemContainer<I extends io.github.mmm.code.api.item.CodeItem> extends BaseNodeItem implements io.github.mmm.code.api.node.CodeNodeItemContainer<I>
Base implementation of CodeNodeItemContainer.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Constructor Details

    • BaseNodeItemContainer

      protected BaseNodeItemContainer()
      The constructor.
    • BaseNodeItemContainer

      public BaseNodeItemContainer(BaseNodeItemContainer<I> template, io.github.mmm.code.api.copy.CodeCopyMapper mapper)
      The copy-constructor.
      Parameters:
      template - the BaseNodeItemContainer to copy.
      mapper - the CodeCopyMapper.
  • Method Details

    • getItemCopyType

      protected io.github.mmm.code.api.copy.CodeCopyType getItemCopyType()
      Returns:
      the CodeCopyType for the items in this container.
    • doSetImmutable

      protected void doSetImmutable()
      Description copied from class: BaseMutableItem
      Called on the first call of BaseMutableItem.setImmutable(). Has to be overridden to update Collections, make child items immutable, etc.
      Overrides:
      doSetImmutable in class BaseMutableItem
    • isSystemImmutable

      protected boolean isSystemImmutable()
      Overrides:
      isSystemImmutable in class BaseMutableItem
      Returns:
      true if this is a system internal node item that is considered to be immutable but is technically set to immutable during (lazy) initialization. Otherwise false.
    • isKeepListView

      protected boolean isKeepListView()
      Returns:
      true if the List should turn into an immutable view on the original mutable List, false otherwise.
      See Also:
    • isNamed

      protected boolean isNamed()
      Returns:
      true if this is a named container that requires a map, false otherwise.
    • getDeclared

      public final List<? extends I> getDeclared()
      Specified by:
      getDeclared in interface io.github.mmm.code.api.node.CodeNodeContainer<I extends io.github.mmm.code.api.item.CodeItem>
    • getList

      protected List<I> getList()
      Returns:
      the actual List of items.
    • getMap

      protected Map<String,I> getMap()
      Returns:
      the optional Map of the items.
    • clear

      public void clear()
      clears all declared items.
    • rename

      protected void rename(I child, String oldName, String newName, Consumer<String> renamer)
      Parameters:
      child - the child to rename.
      oldName - the old name.
      newName - the new name to be set.
      renamer - the Consumer to actually perform the renaming (that may change the Object.hashCode() of the child).
    • getByName

      protected I getByName(String name)
      Parameters:
      name - the name of the requested item.
      Returns:
      the requested item or null if not found.
    • add

      protected void add(I item)
      Parameters:
      item - the item to add.
    • ensureParent

      protected I ensureParent(I item)
      Parameters:
      item - the item to add.
      Returns:
      the item itself or a copy with this container as parent.
    • addInternal

      protected void addInternal(I item)
      Parameters:
      item - the item to add.
    • getKey

      protected String getKey(I item)
      Parameters:
      item - the item to get the key for.
      Returns:
      the key used to associated the given item in the map.
    • remove

      public boolean remove(I item)
      Specified by:
      remove in interface io.github.mmm.code.api.node.CodeNodeItemContainer<I extends io.github.mmm.code.api.item.CodeItem>