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

io.fmq.frame.Frame.scala Maven / Gradle / Ivy

The newest version!
package io.fmq.frame

import cats.data.NonEmptyList

sealed trait Frame[A] {
  def parts: NonEmptyList[A]
}

object Frame {

  final case class Single[A](value: A) extends Frame[A] {
    override def parts: NonEmptyList[A] = NonEmptyList.one(value)
  }

  final case class Multipart[A](header: A, body: NonEmptyList[A]) extends Frame[A] {
    override def parts: NonEmptyList[A] = body.prepend(header)
  }

  object Multipart {

    @SuppressWarnings(Array("org.wartremover.warts.Overloading"))
    def apply[A](header: A, next: A, rest: A*): Multipart[A] =
      Multipart(header, NonEmptyList(next, rest.toList))

  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy