com.softicar.platform.common.container.matrix.simple.SimpleMatrixRowMap 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.core.utils.CastUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
class SimpleMatrixRowMap implements Map {
private final SimpleMatrix matrix;
private final R row;
public SimpleMatrixRowMap(SimpleMatrix matrix, R row) {
this.matrix = matrix;
this.row = row;
}
@Override
public int size() {
return matrix.getColumnCount();
}
@Override
public boolean isEmpty() {
return matrix.getColumnCount() != 0;
}
@Override
public boolean containsKey(Object column) {
return matrix.containsColumn(CastUtils. cast(column));
}
@Override
public boolean containsValue(Object value) {
throw new UnsupportedOperationException();
}
@Override
public V get(Object column) {
return matrix.getValue(row, CastUtils. cast(column));
}
@Override
public V put(C column, V value) {
V previous = matrix.getValue(row, column);
matrix.setValue(row, column, value);
return previous;
}
@Override
public V remove(Object key) {
V value = get(key);
matrix.removeValue(row, CastUtils. cast(key));
return value;
}
@Override
public void putAll(Map m) {
for (Entry entry: m.entrySet()) {
put(entry.getKey(), entry.getValue());
}
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public Set keySet() {
return matrix.getColumns();
}
@Override
public Collection values() {
Collection values = new ArrayList<>();
for (C column: keySet()) {
values.add(matrix.getValue(row, column));
}
return values;
}
@Override
public Set> entrySet() {
throw new UnsupportedOperationException();
}
}