io.github.vmzakharov.ecdataframe.dataframe.DfStringColumn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dataframe-ec Show documentation
Show all versions of dataframe-ec Show documentation
A tabular data structure based on the Eclipse Collections framework
The newest version!
package io.github.vmzakharov.ecdataframe.dataframe;
import io.github.vmzakharov.ecdataframe.dataframe.compare.StringComparisonResult;
import io.github.vmzakharov.ecdataframe.dsl.value.StringValue;
import io.github.vmzakharov.ecdataframe.dsl.value.Value;
import io.github.vmzakharov.ecdataframe.dsl.value.ValueType;
public interface DfStringColumn
extends DfObjectColumn
{
@Override
default String getValueAsString(int rowIndex)
{
return this.getTypedObject(rowIndex);
}
@Override
default String getValueAsStringLiteral(int rowIndex)
{
String value = this.getTypedObject(rowIndex);
return value == null ? "" : '"' + this.getValueAsString(rowIndex) + '"';
}
@Override
default ValueType getType()
{
return ValueType.STRING;
}
@Override
default Value objectToValue(String anObject)
{
return new StringValue(anObject);
}
@Override
default void addRowToColumn(int rowIndex, DfColumn target)
{
target.addObject(this.getTypedObject(rowIndex));
}
@Override
default DfCellComparator columnComparator(DfColumn otherColumn)
{
DfStringColumn otherStringColumn = (DfStringColumn) otherColumn;
return (thisRowIndex, otherRowIndex) -> new StringComparisonResult(
this.getTypedObject(this.dataFrameRowIndex(thisRowIndex)),
otherStringColumn.getTypedObject(otherStringColumn.dataFrameRowIndex(otherRowIndex)));
}
}