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

io.cucumber.scala.ScalaDefaultDataTableCellTransformerDefinition.scala Maven / Gradle / Ivy

There is a newer version: 8.24.0
Show newest version
package io.cucumber.scala

import java.lang.reflect.Type

import io.cucumber.core.backend.{
  DefaultDataTableCellTransformerDefinition,
  ScenarioScoped
}
import io.cucumber.datatable.TableCellByTypeTransformer

trait ScalaDefaultDataTableCellTransformerDefinition
    extends DefaultDataTableCellTransformerDefinition
    with AbstractDatatableElementTransformerDefinition {

  val details: ScalaDefaultDataTableCellTransformerDetails

  override val emptyPatterns: Seq[String] = details.emptyPatterns

  override val location: StackTraceElement = new Exception().getStackTrace()(3)

  override val tableCellByTypeTransformer: TableCellByTypeTransformer =
    (fromValue: String, toTypeValue: Type) => {
      details.body.apply(
        replaceEmptyPatternsWithEmptyString(fromValue),
        toTypeValue
      )
    }

}

object ScalaDefaultDataTableCellTransformerDefinition {

  def apply(
      details: ScalaDefaultDataTableCellTransformerDetails,
      scenarioScoped: Boolean
  ): ScalaDefaultDataTableCellTransformerDefinition = {
    if (scenarioScoped) {
      new ScalaScenarioScopedDataTableCellTransformerDefinition(details)
    } else {
      new ScalaGlobalDataTableCellTransformerDefinition(details)
    }
  }

}

class ScalaScenarioScopedDataTableCellTransformerDefinition(
    override val details: ScalaDefaultDataTableCellTransformerDetails
) extends ScalaDefaultDataTableCellTransformerDefinition
    with ScenarioScoped {}

class ScalaGlobalDataTableCellTransformerDefinition(
    override val details: ScalaDefaultDataTableCellTransformerDetails
) extends ScalaDefaultDataTableCellTransformerDefinition {}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy