Class ObjectCollectionWithProperties

Object
ObjectCollectionWithProperties
All Implemented Interfaces:
Iterable<ObjectWithProperties>

public class ObjectCollectionWithProperties extends Object implements Iterable<ObjectWithProperties>
Like an ObjectCollection but each object has associated properties.

Like a ObjectCollection, it is backed internally by an ArrayList, offering add operations in constant time, and other operations in linear-time.

Author:
Owen Feehan
  • Constructor Details

    • ObjectCollectionWithProperties

      public ObjectCollectionWithProperties(int capacity)
      Create with zero objects.
      Parameters:
      capacity - the capacity of the internally created list.
    • ObjectCollectionWithProperties

      public ObjectCollectionWithProperties(ObjectMask object)
      Create with a single object.
      Parameters:
      object - the object.
    • ObjectCollectionWithProperties

      public ObjectCollectionWithProperties(Stream<ObjectWithProperties> objects)
      Create with a stream of objects with properties.
      Parameters:
      objects - the objects.
    • ObjectCollectionWithProperties

      public ObjectCollectionWithProperties(ObjectCollection objects)
      Create with a stream of objects, assign empty properties to each.
      Parameters:
      objects - the objects.
  • Method Details

    • add

      public void add(ObjectMask object)
      Add an ObjectMask to the collection, assigning empty properties to it.
      Parameters:
      object - the object.
    • add

      public void add(ObjectWithProperties object)
      Add an ObjectWithProperties to the collection.
      Parameters:
      object - the object.
    • get

      public ObjectWithProperties get(int index)
      Get an item at a particular index.
      Parameters:
      index - the index.
      Returns:
      the corresponding item.
    • iterator

      public Iterator<ObjectWithProperties> iterator()
      Specified by:
      iterator in interface Iterable<ObjectWithProperties>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withoutProperties

      public ObjectCollection withoutProperties()
      Returns the contained-objects without the corresponding properties.

      This is an immutable operation.

      Returns:
      the a newly created ObjectCollection containing the same objects as the current collection, but without any associated properties.
    • size

      public int size()
      Number of objects in the collection.
      Returns:
      the size of the collection.
    • isEmpty

      public boolean isEmpty()
      Whether the number of objects is zero.
      Returns:
      true when no objects are contained in the collection, false if at least one object exists.