chibenwa commented on a change in pull request #391:
URL: https://github.com/apache/james-project/pull/391#discussion_r615556747
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/TypeNameFactory.scala
##########
@@ -0,0 +1,16 @@
+package org.apache.james.jmap.change
+
+import javax.inject.Inject
+import scala.jdk.CollectionConverters._
+
+case class TypeNameFactory @Inject()(setTypeName: java.util.Set[TypeName]) {
+ val all: scala.collection.mutable.Set[TypeName] = setTypeName.asScala
+
+ def parse(string: String): Either[IllegalArgumentException, TypeName] = {
+ all.foreach(typeName => typeName.parse(string).fold(
+ e => e.printStackTrace(),
Review comment:
I think we can safely discard the error here (`{}`)
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/TypeNameFactory.scala
##########
@@ -0,0 +1,16 @@
+package org.apache.james.jmap.change
+
+import javax.inject.Inject
+import scala.jdk.CollectionConverters._
+
+case class TypeNameFactory @Inject()(setTypeName: java.util.Set[TypeName]) {
+ val all: scala.collection.mutable.Set[TypeName] = setTypeName.asScala
+
+ def parse(string: String): Either[IllegalArgumentException, TypeName] = {
+ all.foreach(typeName => typeName.parse(string).fold(
+ e => e.printStackTrace(),
+ validTypeName => return Right(validTypeName)))
Review comment:
avoid return in scala
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/change/StateChange.scala
##########
@@ -46,62 +46,70 @@ trait TypeName {
.getOrElse(Map())
def asString(): String
- def parse(string: String): TypeName
+ def parse(string: String): Either[IllegalArgumentException, TypeName]
Review comment:
Or... `Option[TypeName]` as we go through all value, generating an error
is not meaningful...
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]