com.softicar.platform.common.container.matrix.simple.SimpleMatrixCellIterable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.container.matrix.simple;
import com.softicar.platform.common.container.iterator.AbstractIteratorAdapter;
import com.softicar.platform.common.container.matrix.IMatrixCell;
import java.util.Iterator;
import java.util.Map;
class SimpleMatrixCellIterable extends AbstractIteratorAdapter> {
private final Iterator>> rowIterator;
private Iterator> columnIterator;
private Map.Entry> row;
public SimpleMatrixCellIterable(Map> matrixValues) {
this.rowIterator = matrixValues.entrySet().iterator();
}
@Override
protected IMatrixCell fetchNext() {
if (columnIterator == null || !columnIterator.hasNext()) {
if (!rowIterator.hasNext()) {
setFinished();
return null;
}
row = rowIterator.next();
columnIterator = row.getValue().entrySet().iterator();
return fetchNext();
} else {
Map.Entry column = columnIterator.next();
return new SimpleMatrixCell<>(row.getKey(), column.getKey(), column.getValue());
}
}
}