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

com.opengamma.strata.calc.runner.AbstractDerivedCalculationFunction Maven / Gradle / Ivy

/*
 * Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.strata.calc.runner;

import java.util.Set;

import com.google.common.collect.ImmutableSet;
import com.opengamma.strata.basics.CalculationTarget;
import com.opengamma.strata.basics.ReferenceData;
import com.opengamma.strata.calc.Measure;

/**
 * Abstract derived calculation function with fields for the target type, measure and required measures.
 * 

* Empty requirements are returned from {@link #requirements}. * Subtypes only need to provide an implementation of the {@link #calculate} method. * * @param the type of calculation target handled by the function * @param the type of the measure calculated by the function */ public abstract class AbstractDerivedCalculationFunction implements DerivedCalculationFunction { /** The target type handled by the function, often a trade. */ private final Class targetType; /** The measure calculated by the function. */ private final Measure measure; /** The measures required as inputs to the calculation. */ private final Set requiredMeasures; /** * Creates a new function which calculates one measure for targets of one type. * * @param targetType the target type handled by the function, often a trade * @param measure the measure calculated by the function * @param requiredMeasures the measures required as inputs to the calculation */ protected AbstractDerivedCalculationFunction( Class targetType, Measure measure, Measure... requiredMeasures) { this(targetType, measure, ImmutableSet.copyOf(requiredMeasures)); } /** * Creates a new function which calculates one measure for targets of one type. * * @param targetType the target type handled by the function, often a trade * @param measure the measure calculated by the function * @param requiredMeasures the measures required as inputs to the calculation */ protected AbstractDerivedCalculationFunction( Class targetType, Measure measure, Set requiredMeasures) { this.measure = measure; this.requiredMeasures = ImmutableSet.copyOf(requiredMeasures); this.targetType = targetType; } @Override public Class targetType() { return targetType; } @Override public Measure measure() { return measure; } @Override public Set requiredMeasures() { return requiredMeasures; } @Override public FunctionRequirements requirements(T target, CalculationParameters parameters, ReferenceData refData) { return FunctionRequirements.empty(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy