Class ModelList

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Model>, Collection<Model>, List<Model>, RandomAccess, SequencedCollection<Model>

class ModelList extends 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.
  • Constructor Details

    • 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 Details

    • 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 Collection<Model>
      Specified by:
      isEmpty in interface List<Model>
      Overrides:
      isEmpty in class 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