Skip to content

Commit

Permalink
More 2.12 madness
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Gee <andrew.gee@itv.com> 🫥
  • Loading branch information
JosBogan committed Jul 10, 2024
1 parent e123926 commit 7e0dc47
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,23 @@ class Fs2RabbitAmqpClient[F[_]: Async](
override def declare(declarations: decl.Declaration*): F[Unit] = declare(declarations.toList)

override def declare(declarations: Iterable[decl.Declaration]): F[Unit] = {

def mapToSafeArg(kv: (String, AnyRef)): (String, SafeArg) = kv match {
case (k, arg: String) => k -> arg
case (k, arg: BigDecimal) => k -> arg
case (k, arg: Integer) => k -> arg.intValue()
case (k, arg: java.lang.Long) => k -> arg.longValue()
case (k, arg: java.lang.Double) => k -> arg.doubleValue()
case (k, arg: java.lang.Float) => k -> arg.floatValue()
case (k, arg: java.lang.Short) => k -> arg.shortValue()
case (k, arg: java.lang.Boolean) => k -> arg.booleanValue()
case (k, arg: java.lang.Byte) => k -> arg.byteValue()
case (k, arg: java.util.Date) => k -> arg
case t => throw new IllegalArgumentException(s"Unsupported type for rabbit arguments $t")
}

def argumentsFromAnyRef(arguments: Map[String, AnyRef]): Map[String, SafeArg] =
arguments
.map[String, SafeArg] {
case (k, arg: String) => k -> arg
case (k, arg: BigDecimal) => k -> arg
case (k, arg: Integer) => k -> arg.intValue()
case (k, arg: java.lang.Long) => k -> arg.longValue()
case (k, arg: java.lang.Double) => k -> arg.doubleValue()
case (k, arg: java.lang.Float) => k -> arg.floatValue()
case (k, arg: java.lang.Short) => k -> arg.shortValue()
case (k, arg: java.lang.Boolean) => k -> arg.booleanValue()
case (k, arg: java.lang.Byte) => k -> arg.byteValue()
case (k, arg: java.util.Date) => k -> arg
case t => throw new IllegalArgumentException(s"Unsupported type for rabbit arguments $t")
}
arguments.map(mapToSafeArg)

def exchangeTypeToFs2ExchangeType(exchangeType: ExchangeType): model.ExchangeType =
exchangeType match {
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pgpPassphrase := Option(System.getenv("GPG_KEY_PASSPHRASE")).map(_.toArray)

lazy val kernelSettings = Seq(
crossScalaVersions := Seq(scala212, scala213),
scalaVersion := scala213,
scalaVersion := scala212,
organization := "com.itv",
scalacOptions ++= Seq("-feature", "-deprecation", "-Xfatal-warnings", "-language:higherKinds"),
publishTo := {
Expand Down

0 comments on commit 7e0dc47

Please sign in to comment.