Package com.opengamma.strata.loader.csv
Class SecurityTradeCsvPlugin
- java.lang.Object
-
- com.opengamma.strata.loader.csv.SecurityTradeCsvPlugin
-
- All Implemented Interfaces:
Named
,TradeCsvParserPlugin
,TradeCsvWriterPlugin<SecurityQuantityTrade>
public class SecurityTradeCsvPlugin extends Object implements TradeCsvParserPlugin, TradeCsvWriterPlugin<SecurityQuantityTrade>
Handles the CSV file format for Security trades.
-
-
Field Summary
Fields Modifier and Type Field Description static SecurityTradeCsvPlugin
INSTANCE
The singleton instance of the plugin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getName()
Gets the name that uniquely identifies this parser.Set<String>
headers(List<SecurityQuantityTrade> trades)
Returns the set of headers needed for this type of trade.Optional<Trade>
parseTrade(Class<?> requiredJavaType, CsvRow baseRow, List<CsvRow> additionalRows, TradeInfo info, TradeCsvInfoResolver resolver)
Parses a single CSV format trade from the input.Set<Class<?>>
supportedTradeTypes()
Provides the supported trade types for this plugin.Set<String>
tradeTypeNames()
Returns the upper-case product type names that this plugin supports.void
writeCsv(CsvOutput.CsvRowOutputWithHeaders csv, SecurityQuantityTrade trade)
Writes the CSV for the specified trade.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.loader.csv.TradeCsvParserPlugin
isAdditionalRow
-
-
-
-
Field Detail
-
INSTANCE
public static final SecurityTradeCsvPlugin INSTANCE
The singleton instance of the plugin.
-
-
Method Detail
-
tradeTypeNames
public Set<String> tradeTypeNames()
Description copied from interface:TradeCsvParserPlugin
Returns the upper-case product type names that this plugin supports.These are matched against the CSV file type column.
- Specified by:
tradeTypeNames
in interfaceTradeCsvParserPlugin
- Returns:
- the types that this plugin supports
-
parseTrade
public Optional<Trade> parseTrade(Class<?> requiredJavaType, CsvRow baseRow, List<CsvRow> additionalRows, TradeInfo info, TradeCsvInfoResolver resolver)
Description copied from interface:TradeCsvParserPlugin
Parses a single CSV format trade from the input.This parses a single trade from the CSV rows provided. The trade may exist on multiple rows
- Specified by:
parseTrade
in interfaceTradeCsvParserPlugin
- Parameters:
requiredJavaType
- the Java type to returnbaseRow
- the base row to parseadditionalRows
- the additional rows to parse, may be emptyinfo
- the trade inforesolver
- the resolver- Returns:
- the trade object, empty if choosing not to parse because the Java type does not match
-
headers
public Set<String> headers(List<SecurityQuantityTrade> trades)
Description copied from interface:TradeCsvWriterPlugin
Returns the set of headers needed for this type of trade.The headers are ordered and all distinct.
- Specified by:
headers
in interfaceTradeCsvWriterPlugin<SecurityQuantityTrade>
- Parameters:
trades
- the trades to output- Returns:
- the set of additional headers
-
writeCsv
public void writeCsv(CsvOutput.CsvRowOutputWithHeaders csv, SecurityQuantityTrade trade)
Description copied from interface:TradeCsvWriterPlugin
Writes the CSV for the specified trade.- Specified by:
writeCsv
in interfaceTradeCsvWriterPlugin<SecurityQuantityTrade>
- Parameters:
csv
- the CSV to write totrade
- the trade to output
-
getName
public String getName()
Description copied from interface:TradeCsvParserPlugin
Gets the name that uniquely identifies this parser.The name should typically be the name of the
Product
that can be parsed. For example, 'Fra', 'Swap' or 'FxSingle'.This name is used in serialization and can be parsed using
TradeCsvParserPlugin.of(String)
.- Specified by:
getName
in interfaceNamed
- Specified by:
getName
in interfaceTradeCsvParserPlugin
- Specified by:
getName
in interfaceTradeCsvWriterPlugin<SecurityQuantityTrade>
- Returns:
- the unique name
-
supportedTradeTypes
public Set<Class<?>> supportedTradeTypes()
Description copied from interface:TradeCsvWriterPlugin
Provides the supported trade types for this plugin.The set typically contains the names of the
Trade
that can be written. For example, 'FraTrade', 'SwapTrade'.- Specified by:
supportedTradeTypes
in interfaceTradeCsvWriterPlugin<SecurityQuantityTrade>
- Returns:
- the set of supported trade types.
-
-