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

org.jsapar.compose.string.StringLineComposerNullOnEmptyCell Maven / Gradle / Ivy

Go to download

JSaPar is a Java library providing a schema based parser and composer of almost collected sorts of delimited and fixed width files.

The newest version!
package org.jsapar.compose.string;

import org.jsapar.model.Line;
import org.jsapar.schema.SchemaCell;
import org.jsapar.schema.SchemaLine;

import java.util.stream.Stream;

public final class StringLineComposerNullOnEmptyCell extends StringLineComposer {
    StringLineComposerNullOnEmptyCell(SchemaLine schemaLine) {
        super(schemaLine);
    }

    @Override
    Stream composeStringLine(Line line) {
        return getCellComposers().stream().map(cellComposer ->
             line.getCell(cellComposer.getName())
                    .map(cellComposer::compose)
                    .map(s->s.isEmpty() && !cellComposer.isDefaultValue() ? null : s)
                    .orElseGet(()-> cellComposer.isDefaultValue() ? cellComposer.compose(cellComposer.makeEmptyCell()) : null)

        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy