Spring Data Commons

org.springframework.data.history
Class Revisions<N extends Number & Comparable<N>,T>

java.lang.Object
  extended by org.springframework.data.history.Revisions<N,T>
All Implemented Interfaces:
Iterable<Revision<N,T>>

public class Revisions<N extends Number & Comparable<N>,T>
extends Object
implements Iterable<Revision<N,T>>

Simple wrapper class for a List of Revisions allowing to canonically access the latest revision. Allows iterating over the underlying Revisions starting with older revisions.

Author:
Oliver Gierke

Constructor Summary
Revisions(List<? extends Revision<N,T>> revisions)
          Creates a new Revisions instance containing the given revisions.
 
Method Summary
 List<Revision<N,T>> getContent()
          Returns the content of the Revisions instance.
 Revision<N,T> getLatestRevision()
          Returns the latest revision of the revisions backing the wrapper independently of the order.
 Iterator<Revision<N,T>> iterator()
           
 Revisions<N,T> reverse()
          Reverses the current Revisions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Revisions

public Revisions(List<? extends Revision<N,T>> revisions)
Creates a new Revisions instance containing the given revisions. Will make sure they are ordered ascendingly.

Parameters:
revisions - must not be null.
Method Detail

getLatestRevision

public Revision<N,T> getLatestRevision()
Returns the latest revision of the revisions backing the wrapper independently of the order.

Returns:

reverse

public Revisions<N,T> reverse()
Reverses the current Revisions. By default this will return the revisions with the latest revision first.

Returns:

iterator

public Iterator<Revision<N,T>> iterator()
Specified by:
iterator in interface Iterable<Revision<N extends Number & Comparable<N>,T>>

getContent

public List<Revision<N,T>> getContent()
Returns the content of the Revisions instance.

Returns:

Spring Data Commons

Copyright © 2012. All Rights Reserved.