예제 #1
0
        public override EvaluationResult evaluate(ResultsRow resultsRow, CalculationFunctions functions, string firstToken, IList <string> remainingTokens)
        {
            ValueRootType rootType = ValueRootType.parseToken(firstToken);

            switch (rootType.innerEnumValue)
            {
            case com.opengamma.strata.report.framework.expression.ValueRootType.InnerEnum.MEASURES:
                return(evaluateMeasures(resultsRow, functions, remainingTokens));

            case com.opengamma.strata.report.framework.expression.ValueRootType.InnerEnum.PRODUCT:
                return(EvaluationResult.of(resultsRow.Product, remainingTokens));

            case com.opengamma.strata.report.framework.expression.ValueRootType.InnerEnum.SECURITY:
                return(EvaluationResult.of(resultsRow.Security, remainingTokens));

            case com.opengamma.strata.report.framework.expression.ValueRootType.InnerEnum.TRADE:
                return(EvaluationResult.of(resultsRow.Trade, remainingTokens));

            case com.opengamma.strata.report.framework.expression.ValueRootType.InnerEnum.POSITION:
                return(EvaluationResult.of(resultsRow.Position, remainingTokens));

            case com.opengamma.strata.report.framework.expression.ValueRootType.InnerEnum.TARGET:
                return(EvaluationResult.success(resultsRow.Target, remainingTokens));

            default:
                throw new System.ArgumentException("Unknown root token '" + rootType.token() + "'");
            }
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Gets the measure encoded in a value path, if present.
        /// </summary>
        /// <param name="valuePath">  the value path </param>
        /// <returns> the measure, if present </returns>
        public static Optional <Measure> measure(string valuePath)
        {
            try
            {
                IList <string> tokens   = tokenize(valuePath);
                ValueRootType  rootType = ValueRootType.parseToken(tokens[0]);

                if (rootType != ValueRootType.MEASURES || tokens.Count < 2)
                {
                    return(null);
                }
                Measure measure = Measure.of(tokens[1]);
                return(measure);
            }
            catch (Exception)
            {
                return(null);
            }
        }