Package com.opengamma.strata.loader.csv
Class FxNdfTradeCsvPlugin
- java.lang.Object
-
- com.opengamma.strata.loader.csv.FxNdfTradeCsvPlugin
-
- All Implemented Interfaces:
Named
,TradeCsvParserPlugin
,TradeCsvWriterPlugin<FxNdfTrade>
public class FxNdfTradeCsvPlugin extends Object implements TradeCsvParserPlugin, TradeCsvWriterPlugin<FxNdfTrade>
Handles the CSV file format for FxNdf trades.
-
-
Field Summary
Fields Modifier and Type Field Description static FxNdfTradeCsvPlugin
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<FxNdfTrade> 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, FxNdfTrade 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 FxNdfTradeCsvPlugin 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
-
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<FxNdfTrade>
- 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<FxNdfTrade>
- Returns:
- the set of supported trade types.
-
headers
public Set<String> headers(List<FxNdfTrade> 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<FxNdfTrade>
- Parameters:
trades
- the trades to output- Returns:
- the set of additional headers
-
writeCsv
public void writeCsv(CsvOutput.CsvRowOutputWithHeaders csv, FxNdfTrade trade)
Description copied from interface:TradeCsvWriterPlugin
Writes the CSV for the specified trade.- Specified by:
writeCsv
in interfaceTradeCsvWriterPlugin<FxNdfTrade>
- Parameters:
csv
- the CSV to write totrade
- the trade to output
-
-