Search in sources :

Example 1 with Datatype

use of io.fixprotocol._2020.orchestra.repository.Datatype in project fix-orchestra by FIXTradingCommunity.

the class CodeSetScope method resolve.

/*
   * (non-Javadoc)
   *
   * @see
   * io.fixprotocol.orchestra.dsl.antlr.Scope#resolve(io.fixprotocol.orchestra.dsl.antlr.PathStep)
   */
@SuppressWarnings("unchecked")
@Override
public FixValue<?> resolve(PathStep pathStep) {
    final String dataTypeString = codeSet.getType();
    final FixType dataType = FixType.forName(dataTypeString);
    final String name = pathStep.getName();
    final List<CodeType> codes = codeSet.getCode();
    for (final CodeType code : codes) {
        if (code.getName().equals(name)) {
            @SuppressWarnings("rawtypes") FixValue fixValue;
            try {
                fixValue = FixValueFactory.create(name, dataType, dataType.getValueClass());
                fixValue.setValue(dataType.getValueClass().cast(dataType.fromString(code.getValue())));
                return fixValue;
            } catch (final ModelException e) {
                return null;
            }
        }
    }
    return null;
}
Also used : FixValue(io.fixprotocol.orchestra.model.FixValue) ModelException(io.fixprotocol.orchestra.model.ModelException) CodeType(io.fixprotocol._2020.orchestra.repository.CodeType) FixType(io.fixprotocol.orchestra.model.FixType)

Aggregations

CodeType (io.fixprotocol._2020.orchestra.repository.CodeType)1 FixType (io.fixprotocol.orchestra.model.FixType)1 FixValue (io.fixprotocol.orchestra.model.FixValue)1 ModelException (io.fixprotocol.orchestra.model.ModelException)1