implement iterable interface

This commit is contained in:
Sebastian Sdorra
2012-06-26 08:20:31 +02:00
parent ee0e34341d
commit f9affd47b8

View File

@@ -36,11 +36,13 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -59,7 +61,7 @@ import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement(name = "blame-result")
@XmlAccessorType(XmlAccessType.FIELD)
public class BlameResult implements Serializable
public class BlameResult implements Serializable, Iterable<BlameLine>
{
/** Field description */
@@ -139,6 +141,20 @@ public class BlameResult implements Serializable
return Objects.hashCode(total, blameLines);
}
/**
* Method description
*
*
* @return
*
* @since 1.17
*/
@Override
public Iterator<BlameLine> iterator()
{
return getBlameLines().iterator();
}
/**
* {@inheritDoc}
*
@@ -166,6 +182,9 @@ public class BlameResult implements Serializable
*/
public List<BlameLine> getBlameLines()
{
if ( blameLines == null ){
blameLines = Lists.newArrayList();
}
return blameLines;
}