All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softicar.platform.common.container.matrix.simple.SimpleMatrixCellIterable Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
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());
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy