Class ModelList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Model>, java.util.Collection<Model>, java.util.List<Model>, java.util.RandomAccess

    class ModelList
    extends java.util.ArrayList<Model>
    The ModelList object is used to maintain an ordered list of models. Models are maintained within the list in an sequenced manner, ordered by the index of the model. During the building process models can be registered in any order, however once building has finished the list must contain a complete sequence of models, ordered by index.
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      ModelList()
      Constructor for the ModelList object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ModelList build()
      This is used when building a copy of the model.
      boolean isEmpty()
      This is used to determine if the model list is empty.
      Model lookup​(int index)
      This is used to find a model based on its index.
      void register​(Model model)
      This is used to register the model within the list.
      Model take()
      This is used to take the models from the model list at the first index.
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.util.List

        containsAll
    • Constructor Detail

      • ModelList

        public ModelList()
        Constructor for the ModelList object. This is used to construct a linked list that can take registrations of Model objects out of sequence. Once complete the list should contain a full ordered set of models.
    • Method Detail

      • build

        public ModelList build()
        This is used when building a copy of the model. A copy is required when serializing or deserializing so that the list remains intact for the next time it is used
        Returns:
        this returns an exact copy of the model list
      • isEmpty

        public boolean isEmpty()
        This is used to determine if the model list is empty. The model list is considered empty if it does not contain any models with element or attribute registrations. This does not mean that the list itself does not contain models.
        Specified by:
        isEmpty in interface java.util.Collection<Model>
        Specified by:
        isEmpty in interface java.util.List<Model>
        Overrides:
        isEmpty in class java.util.ArrayList<Model>
        Returns:
        this returns true if there are no registrations
      • lookup

        public Model lookup​(int index)
        This is used to find a model based on its index. If there are no models at the specified index this will return null. Unlike the get method this does not throw exceptions.
        Parameters:
        index - this is the index to acquire the model at
        Returns:
        this returns the model if one exists at the index
      • register

        public void register​(Model model)
        This is used to register the model within the list. The model is registered at the index provided. If the registration is out of sequence all indexes that do not have models are populated with null values to ensure each model resides in its index position within the list.
        Parameters:
        model - the model to be registered within the list
      • take

        public Model take()
        This is used to take the models from the model list at the first index. This is used when iterating over the models to ensure there is only ever one visit of a specific model
        Returns:
        this returns the next model in the sequence