<commit_before>/**
 * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.engine.fudgemsg;

import java.util.Set;

import org.fudgemsg.FudgeField;
import org.fudgemsg.FudgeMsg;
import org.fudgemsg.MutableFudgeMsg;
import org.fudgemsg.mapping.FudgeBuilder;
import org.fudgemsg.mapping.FudgeBuilderFor;
import org.fudgemsg.mapping.FudgeDeserializer;
import org.fudgemsg.mapping.FudgeSerializer;

import com.opengamma.engine.value.ComputedValueResult;
import com.opengamma.engine.value.ValueSpecification;
import com.opengamma.engine.view.calcnode.ExecutionLog;
import com.opengamma.engine.view.calcnode.InvocationResult;

/**
 * Fudge message builder for {@link ComputedValueResult}.
 */
@FudgeBuilderFor(ComputedValueResult.class)
public class ComputedValueResultFudgeBuilder implements FudgeBuilder<ComputedValueResult> {

  private static final String EXECUTION_LOG_FIELD = "executionLog";
  private static final String COMPUTE_NODE_ID_FIELD = "computeNodeId";
  private static final String MISSING_INPUTS_FIELD_NAME = "missingInputs";
  private static final String INVOCATION_RESULT_FIELD_NAME = "result";
  
  @Override
  public MutableFudgeMsg buildMessage(FudgeSerializer serializer, ComputedValueResult object) {
    MutableFudgeMsg msg = serializer.newMessage();
    ComputedValueFudgeBuilder.appendToMsg(serializer, object, msg);
    serializer.addToMessage(msg, EXECUTION_LOG_FIELD, null, object);
    if (object.getComputeNodeId() != null) {
      msg.add(COMPUTE_NODE_ID_FIELD, object.getComputeNodeId());
    }
    if (object.getMissingInputs() != null) {
      serializer.addToMessage(msg, MISSING_INPUTS_FIELD_NAME, null, object.getMissingInputs());
    }
    if (object.getInvocationResult() != null) {
      serializer.addToMessage(msg, INVOCATION_RESULT_FIELD_NAME, null, object.getInvocationResult());
    }
    return msg;
  }

  @SuppressWarnings("unchecked")
  @Override
  public ComputedValueResult buildObject(FudgeDeserializer deserializer, FudgeMsg msg) {
    ValueSpecification valueSpec = ComputedValueFudgeBuilder.getValueSpecification(deserializer, msg);
    Object valueObject = ComputedValueFudgeBuilder.getValueObject(deserializer, msg);
    ExecutionLog executionLog = deserializer.fieldValueToObject(ExecutionLog.class, msg.getByName(EXECUTION_LOG_FIELD));
    String computeNodeId = msg.getString(COMPUTE_NODE_ID_FIELD);
    FudgeField missingInputsField = msg.getByName(MISSING_INPUTS_FIELD_NAME);
    Set<ValueSpecification> missingInputs = missingInputsField != null ? deserializer.fieldValueToObject(Set.class, missingInputsField) : null;
    String invocationResultName = msg.getString(INVOCATION_RESULT_FIELD_NAME);<commit_msg>[PLAT-2779] Fixing bug<commit_after>/**
 * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.engine.fudgemsg;

import java.util.Set;

import org.fudgemsg.FudgeField;
import org.fudgemsg.FudgeMsg;
import org.fudgemsg.MutableFudgeMsg;
import org.fudgemsg.mapping.FudgeBuilder;
import org.fudgemsg.mapping.FudgeBuilderFor;
import org.fudgemsg.mapping.FudgeDeserializer;
import org.fudgemsg.mapping.FudgeSerializer;

import com.opengamma.engine.value.ComputedValueResult;
import com.opengamma.engine.value.ValueSpecification;
import com.opengamma.engine.view.calcnode.ExecutionLog;
import com.opengamma.engine.view.calcnode.InvocationResult;

/**
 * Fudge message builder for {@link ComputedValueResult}.
 */
@FudgeBuilderFor(ComputedValueResult.class)
public class ComputedValueResultFudgeBuilder implements FudgeBuilder<ComputedValueResult> {

  private static final String EXECUTION_LOG_FIELD = "executionLog";
  private static final String COMPUTE_NODE_ID_FIELD = "computeNodeId";
  private static final String MISSING_INPUTS_FIELD_NAME = "missingInputs";
  private static final String INVOCATION_RESULT_FIELD_NAME = "result";
  
  @Override
  public MutableFudgeMsg buildMessage(FudgeSerializer serializer, ComputedValueResult object) {
    MutableFudgeMsg msg = serializer.newMessage();
    ComputedValueFudgeBuilder.appendToMsg(serializer, object, msg);
    serializer.addToMessage(msg, EXECUTION_LOG_FIELD, null, object.getExecutionLog());
    if (object.getComputeNodeId() != null) {
      msg.add(COMPUTE_NODE_ID_FIELD, object.getComputeNodeId());
    }
    if (object.getMissingInputs() != null) {
      serializer.addToMessage(msg, MISSING_INPUTS_FIELD_NAME, null, object.getMissingInputs());
    }
    if (object.getInvocationResult() != null) {
      serializer.addToMessage(msg, INVOCATION_RESULT_FIELD_NAME, null, object.getInvocationResult());
    }
    return msg;
  }

  @SuppressWarnings("unchecked")
  @Override
  public ComputedValueResult buildObject(FudgeDeserializer deserializer, FudgeMsg msg) {
    ValueSpecification valueSpec = ComputedValueFudgeBuilder.getValueSpecification(deserializer, msg);
    Object valueObject = ComputedValueFudgeBuilder.getValueObject(deserializer, msg);
    ExecutionLog executionLog = deserializer.fieldValueToObject(ExecutionLog.class, msg.getByName(EXECUTION_LOG_FIELD));
    String computeNodeId = msg.getString(COMPUTE_NODE_ID_FIELD);
    FudgeField missingInputsField = msg.getByName(MISSING_INPUTS_FIELD_NAME);
    Set<ValueSpecification> missingInputs = missingInputsField != null ? deserializer.fieldValueToObject(Set.class, missingInputsField) : null;
    String invocationResultName = msg.getString(INVOCATION_RESULT_FIELD_NAME);
{'fraction_non_alphanumeric': 0.0883779414406323, 'fraction_numerical': 0.002155559547332495, 'mean_word_length': 6.203104786545925, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6653017', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1696, 'n_words': 311}