I am getting started with Scala and I am replacing the deprecated JavaConversions library with JavaConverters. I have the following code:
import scala.collection.JavaConversions._
new AMQP.BasicProperties.Builder()
.contentType(message.contentType.map(_.toString).orNull)
.contentEncoding(message.contentEncoding.orNull)
.headers(message.headers) //<<<<--------------- I SEE THE ERROR ON THIS LINE (datatype of message.heads is Map[String, String]
.deliveryMode(toDeliveryMode(message.mode))
.priority(..)
.correlationId(..)
.replyTo(..)
.expiration(..)
.messageId(..)
.timestamp(..)
.`type`(..)
.userId(..)
.appId(..)
.build()
}
When I replace the import for JavaConversions to JavaConverters (or, just comment out the import altogether), I get the compilation exception:
Type mismatch expected: util.Map[String, AnyRef], actual Map[String, String]
What am I missing?
.asJavaobviouslyutil.Map[String, AnyRef]is a Java collectionMap[String, String]is a Scala collection.asJava?