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

com.tecacet.finance.io.parser.BarchartAssetParser Maven / Gradle / Ivy

package com.tecacet.finance.io.parser;

import com.tecacet.finance.model.Asset;
import com.tecacet.finance.model.AssetType;
import com.tecacet.jflat.CSVReader;
import com.tecacet.jflat.RowRecord;
import org.apache.commons.csv.CSVFormat;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Parse Barchart File to extract asset information
 */
public class BarchartAssetParser {

    private final CSVReader reader = CSVReader.readerWithIndexMapping(Asset.class, new String[]{"symbol", "name"})
            .withFormat(CSVFormat.DEFAULT.withDelimiter(':'));

    public List parse(InputStream is, AssetType assetType) throws IOException {
        return reader.readAllWithCallback(is, (RowRecord row, Asset asset) ->
                asset.toBuilder().assetType(assetType).build());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy