com.opengamma.strata.loader.csv.SecurityPositionCsvPlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of strata-loader Show documentation
Show all versions of strata-loader Show documentation
Loaders from standard and Strata-specific data formats
/*
* Copyright (C) 2021 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.strata.loader.csv;
import java.util.Optional;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import com.opengamma.strata.collect.io.CsvRow;
import com.opengamma.strata.product.GenericSecurityPosition;
import com.opengamma.strata.product.Position;
import com.opengamma.strata.product.PositionInfo;
import com.opengamma.strata.product.SecurityPosition;
/**
* Handles the CSV file format for security trades.
*/
final class SecurityPositionCsvPlugin implements PositionCsvParserPlugin {
/**
* The singleton instance of the plugin.
*/
public static final SecurityPositionCsvPlugin INSTANCE = new SecurityPositionCsvPlugin();
//-------------------------------------------------------------------------
@Override
public Set positionTypeNames() {
return ImmutableSet.of("SEC", "SECURITY");
}
@Override
public Optional parsePosition(
Class> requiredJavaType,
CsvRow row,
PositionInfo info,
PositionCsvInfoResolver resolver) {
if (requiredJavaType.isAssignableFrom(GenericSecurityPosition.class)) {
return Optional.of(resolver.parseNonEtdPosition(row, info));
}
if (requiredJavaType.isAssignableFrom(SecurityPosition.class)) {
return Optional.of(resolver.parseNonEtdSecurityPosition(row, info));
}
return Optional.empty();
}
@Override
public String getName() {
return "Security";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy