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 Summary
ConstructorsConstructorDescriptionObjectCollectionWithProperties
(int capacity) Create with zero objects.Create with a stream of objects with properties.Create with a stream of objects, assign empty properties to each.Create with a single object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ObjectWithProperties object) Add anObjectWithProperties
to the collection.void
add
(ObjectMask object) Add anObjectMask
to the collection, assigning empty properties to it.get
(int index) Get an item at a particular index.boolean
isEmpty()
Whether the number of objects is zero.iterator()
int
size()
Number of objects in the collection.toString()
Returns the contained-objects without the corresponding properties.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ObjectCollectionWithProperties
public ObjectCollectionWithProperties(int capacity) Create with zero objects.- Parameters:
capacity
- the capacity of the internally created list.
-
ObjectCollectionWithProperties
Create with a single object.- Parameters:
object
- the object.
-
ObjectCollectionWithProperties
Create with a stream of objects with properties.- Parameters:
objects
- the objects.
-
ObjectCollectionWithProperties
Create with a stream of objects, assign empty properties to each.- Parameters:
objects
- the objects.
-
-
Method Details
-
add
Add anObjectMask
to the collection, assigning empty properties to it.- Parameters:
object
- the object.
-
add
Add anObjectWithProperties
to the collection.- Parameters:
object
- the object.
-
get
Get an item at a particular index.- Parameters:
index
- the index.- Returns:
- the corresponding item.
-
iterator
- Specified by:
iterator
in interfaceIterable<ObjectWithProperties>
-
toString
-
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.
-