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.ArrayList;
import java.util.List;

public class BarchartAssetParser {

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

    public List parse(InputStream is, AssetType assetType) throws IOException {
        List assets = new ArrayList<>();
        reader.read(is, (RowRecord row, Asset asset) -> {
            asset.setAssetType(assetType);
            assets.add(asset);
        });
        return assets;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy