Package com.complexible.common.base
Class ChangeList<E extends java.lang.Enum & ChangeType,T>
- java.lang.Object
-
- com.complexible.common.base.ChangeList<E,T>
-
- Type Parameters:
T
- the type of the change objects
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.lang.Iterable<Change<E,T>>
public final class ChangeList<E extends java.lang.Enum & ChangeType,T> extends java.lang.Object implements java.lang.Iterable<Change<E,T>>, java.lang.AutoCloseable
An ordered list of
changes
to some resource.- Since:
- 3.0
- Version:
- 3.0
- Author:
- Michael Grove
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ChangeList<E,T>
append(Change<E,T> theChange)
Add a new Change to the current list of changesChangeList<E,T>
append(E theType, T theChange)
Add a new Change to the current list of changes.ChangeList<E,T>
appendAll(java.lang.Iterable<Change<E,T>> theChange)
Add all the Changes to the current list of changesvoid
clear()
Clear all changesvoid
close()
Close all the change objects in this liststatic <T,E extends java.lang.Enum & ChangeType>
ChangeList<E,T>create()
Create a new list of Changesboolean
isEmpty()
Return whether or not the ChangeList is emptyjava.util.Iterator<Change<E,T>>
iterator()
int
size()
Return the number of changes in this change set
-
-
-
Method Detail
-
create
public static <T,E extends java.lang.Enum & ChangeType> ChangeList<E,T> create()
Create a new list of Changes- Type Parameters:
T
- the type of payload in the changes- Returns:
- the new ChangeList
-
clear
public void clear()
Clear all changes
-
close
public void close() throws java.lang.Exception
Close all the change objects in this list- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
append
public ChangeList<E,T> append(Change<E,T> theChange)
Add a new Change to the current list of changes- Parameters:
theChange
- the change to add- Returns:
- this ChangeList
-
appendAll
public ChangeList<E,T> appendAll(java.lang.Iterable<Change<E,T>> theChange)
Add all the Changes to the current list of changes- Parameters:
theChange
- the change to add- Returns:
- this ChangeList
-
append
public ChangeList<E,T> append(E theType, T theChange)
Add a new Change to the current list of changes.- Parameters:
theType
- the type of changetheChange
- the change payload- Returns:
- this ChangeList
-
size
public int size()
Return the number of changes in this change set- Returns:
- the number of changes
-
isEmpty
public boolean isEmpty()
Return whether or not the ChangeList is empty- Returns:
- true if there are no changes in this list, false otherwise
-
iterator
public java.util.Iterator<Change<E,T>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<E extends java.lang.Enum & ChangeType>
-
-