<commit_before>package io.github.cloudiator.rest.converter;

import com.google.common.base.Strings;
import de.uniulm.omi.cloudiator.util.TwoWayConverter;
import io.github.cloudiator.rest.model.SparkInterface;
import org.cloudiator.messages.entities.TaskEntities;
import org.cloudiator.messages.entities.TaskEntities.SparkInterface.Builder;

public class SparkInterfaceConverter implements
    TwoWayConverter<SparkInterface, TaskEntities.SparkInterface> {

  @Override
  public SparkInterface applyBack(TaskEntities.SparkInterface sparkInterface) {
    SparkInterface ret = new SparkInterface();
    ret.setFile(sparkInterface.getFile());
    if (!Strings.isNullOrEmpty(sparkInterface.getClassName())) {
      ret.setClassName(sparkInterface.getClassName());
    }
    ret.setArguments(sparkInterface.getArgumentsList());
    ret.setSparkArguments(sparkInterface.getSparkArgumentsMap());
    ret.setSparkConfiguration(sparkInterface.getSparkConfigurationMap());

    return ret;
  }

  @Override
  public TaskEntities.SparkInterface apply(SparkInterface sparkInterface) {

    Builder builder = TaskEntities.SparkInterface.newBuilder();
    builder.setFile(sparkInterface.getFile());
    if (sparkInterface.getClassName() != null) {
      builder.setClassName(sparkInterface.getClassName());
    }

    if (sparkInterface.getArguments() != null) {
      builder.addAllArguments(sparkInterface.getArguments());
    }

    if (sparkInterface.getSparkArguments() != null) {
      builder.putAllSparkArguments(sparkInterface.getSparkArguments());
    }

    if (sparkInterface.getSparkConfiguration() != null) {
      builder.putAllSparkConfiguration(sparkInterface.getSparkConfiguration());
    }

    return builder.build();
  }
}<commit_msg>implemented converter for deployMode enum<commit_after>package io.github.cloudiator.rest.converter;

import com.google.common.base.Strings;
import de.uniulm.omi.cloudiator.util.TwoWayConverter;
import io.github.cloudiator.rest.model.SparkInterface;
import io.github.cloudiator.rest.model.SparkInterface.DeployModeEnum;
import org.cloudiator.messages.entities.TaskEntities;
import org.cloudiator.messages.entities.TaskEntities.DeployMode;
import org.cloudiator.messages.entities.TaskEntities.SparkInterface.Builder;

public class SparkInterfaceConverter implements
    TwoWayConverter<SparkInterface, TaskEntities.SparkInterface> {

  private static final DeployModeConverter DEPLOY_MODE_CONVERTER = new DeployModeConverter();

  @Override
  public SparkInterface applyBack(TaskEntities.SparkInterface sparkInterface) {
    SparkInterface ret = new SparkInterface();
    ret.setFile(sparkInterface.getFile());
    if (!Strings.isNullOrEmpty(sparkInterface.getClassName())) {
      ret.setClassName(sparkInterface.getClassName());
    }
    ret.setArguments(sparkInterface.getArgumentsList());
    ret.setSparkArguments(sparkInterface.getSparkArgumentsMap());
    ret.setSparkConfiguration(sparkInterface.getSparkConfigurationMap());

    ret.setDeployMode(DEPLOY_MODE_CONVERTER.applyBack(sparkInterface.getDeployMode()));

    return ret;
  }

  @Override
  public TaskEntities.SparkInterface apply(SparkInterface sparkInterface) {

    Builder builder = TaskEntities.SparkInterface.newBuilder();
    builder.setFile(sparkInterface.getFile());
    if (sparkInterface.getClassName() != null) {
      builder.setClassName(sparkInterface.getClassName());
    }

    if (sparkInterface.getArguments() != null) {
      builder.addAllArguments(sparkInterface.getArguments());
    }

    if (sparkInterface.getSparkArguments() != null) {
      builder.putAllSparkArguments(sparkInterface.getSparkArguments());
    }

    if (sparkInterface.getSparkConfiguration() != null) {
      builder.putAllSparkConfiguration(sparkInterface.getSparkConfiguration());
    }

    builder.setDeployMode(DEPLOY_MODE_CONVERTER.apply(sparkInterface.getDeployMode()));


    return builder.build();
  }


  private static class DeployModeConverter implements
      TwoWayConverter<DeployModeEnum, TaskEntities.DeployMode> {


    @Override
    public DeployModeEnum applyBack(DeployMode deployMode) {
      switch (deployMode) {

        case SCALE:
          return DeployModeEnum.SCALE;
        case SUBMIT:
          return DeployModeEnum.SUBMIT;
        case SCALE_SUBMIT:
          return DeployModeEnum.SCALE_SUBMIT;
        default:
          throw new AssertionError("Unrecognized deploy mode on message side: " + deployMode);
      }
    }

    @Override
    public DeployMode apply(DeployModeEnum deployModeEnum) {
      switch (deployModeEnum) {
        case SCALE:
          return DeployMode.SCALE;
        case SUBMIT:
          return DeployMode.SUBMIT;
        case SCALE_SUBMIT:
          return DeployMode.SCALE_SUBMIT;
        default:
          throw new AssertionError("Unrecognized deploy mode on REST side: " + deployModeEnum);
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.09604751177554782, 'fraction_numerical': 0.0, 'mean_word_length': 4.450892857142857, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '2657664', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1351, 'n_words': 208}