mdedetrich commented on code in PR #376:
URL: 
https://github.com/apache/incubator-pekko-http/pull/376#discussion_r1433392622


##########
http/src/main/scala/org/apache/pekko/http/javadsl/unmarshalling/Unmarshaller.scala:
##########
@@ -124,6 +124,40 @@ object Unmarshaller extends 
pekko.http.javadsl.unmarshalling.Unmarshallers {
       implicit mi: JavaMapping[JI, SI]): unmarshalling.Unmarshaller[JI, O] =
     um.asInstanceOf[unmarshalling.Unmarshaller[JI, O]] // since guarantee 
provided by existence of `mi`
 
+  class UnsupportedContentTypeException(
+      private val _supported: java.util.Set[jm.model.ContentTypeRange],
+      private val _actualContentType: Optional[jm.model.ContentType])
+      extends RuntimeException(_supported.asScala.mkString(
+        s"Unsupported Content-Type [${_actualContentType.asScala}], supported: 
", ", ", "")) {
+
+    def this(supported: jm.model.ContentTypeRange*) = {
+      this(supported.toSet.asJava, Optional.empty[jm.model.ContentType]())
+    }
+
+    def this(supported: java.util.Set[jm.model.ContentTypeRange]) = {
+      this(supported, Optional.empty[jm.model.ContentType]())
+    }
+
+    def this(contentType: Optional[jm.model.ContentType], supported: 
jm.model.ContentTypeRange*) = {
+      this(supported.toSet.asJava, contentType)
+    }
+
+    def toScala(): 
pekko.http.scaladsl.unmarshalling.Unmarshaller.UnsupportedContentTypeException =
+      
pekko.http.scaladsl.unmarshalling.Unmarshaller.UnsupportedContentTypeException(
+        
_supported.asScala.toSet.asInstanceOf[Set[pekko.http.scaladsl.model.ContentTypeRange]],
+        _actualContentType.asScala)
+
+    def getSupported(): java.util.Set[jm.model.ContentTypeRange] = _supported
+
+    def getActualContentType(): Optional[jm.model.ContentType] = 
_actualContentType
+
+    override def equals(that: Any): Boolean = that match {
+      case that: UnsupportedContentTypeException =>
+        that._supported == this._supported && that._actualContentType == 
this._actualContentType

Review Comment:
   Since it may not be immediately obvious, both `java.util.Set` and 
`java.util.Optional` equals methods perform structural equality, not reference 
(I tested this in Scala repl).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to