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

pl.touk.nussknacker.ui.process.repository.SystemComment.scala Maven / Gradle / Ivy

There is a newer version: 1.17.0
Show newest version
package pl.touk.nussknacker.ui.process.repository

import io.circe.{Decoder, Encoder}
import pl.touk.nussknacker.engine.migration.ProcessMigration
import pl.touk.nussknacker.ui.listener.Comment

sealed trait SystemComment extends Comment

final case class UpdateProcessComment(override val value: String) extends SystemComment {
  require(value.nonEmpty, "Comment can't be empty")
}

object UpdateProcessComment {
  implicit val encoder: Encoder[UpdateProcessComment] = Encoder.encodeString.contramap(_.value)
  implicit val decoder: Decoder[Option[UpdateProcessComment]] =
    Decoder.decodeOption(Decoder.decodeString).map(_.filterNot(_.isEmpty).map(UpdateProcessComment(_)))
}

final case class MigrationComment(migrationsApplied: List[ProcessMigration]) extends SystemComment {

  override def value: String = s"Migrations applied: ${migrationsApplied.map(_.description).mkString(", ")}"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy