From bc32e04b1331c1cf45fc33c3efdcf19847f13d25 Mon Sep 17 00:00:00 2001 From: Matthew de Detrich Date: Tue, 1 Oct 2024 12:19:32 +0200 Subject: [PATCH] Fix CollectionUtil `toSeq` methods Signed-off-by: Matthew de Detrich --- .../pekko/stream/javadsl/CollectionUtil.scala | 2 + .../pekko/stream/javadsl/CollectionUtil.scala | 2 + .../pekko/stream/javadsl/CollectionUtil.scala | 39 +++++++++++++++++++ 3 files changed, 43 insertions(+) rename stream/src/main/{scala-2.13+ => scala-2.13}/org/apache/pekko/stream/javadsl/CollectionUtil.scala (96%) create mode 100644 stream/src/main/scala-3/org/apache/pekko/stream/javadsl/CollectionUtil.scala diff --git a/stream/src/main/scala-2.12/org/apache/pekko/stream/javadsl/CollectionUtil.scala b/stream/src/main/scala-2.12/org/apache/pekko/stream/javadsl/CollectionUtil.scala index 1fc7d88887..a77daba8a6 100644 --- a/stream/src/main/scala-2.12/org/apache/pekko/stream/javadsl/CollectionUtil.scala +++ b/stream/src/main/scala-2.12/org/apache/pekko/stream/javadsl/CollectionUtil.scala @@ -21,6 +21,7 @@ package javadsl import scala.collection.immutable import org.apache.pekko +import pekko.annotation.InternalApi import pekko.japi.Util.immutableSeq /** @@ -28,6 +29,7 @@ import pekko.japi.Util.immutableSeq * * Utility methods for converting Java collections to Scala collections. */ +@InternalApi private[javadsl] object CollectionUtil { @inline def toSeq[T](jlist: java.util.List[T]): immutable.Seq[T] = immutableSeq(jlist) diff --git a/stream/src/main/scala-2.13+/org/apache/pekko/stream/javadsl/CollectionUtil.scala b/stream/src/main/scala-2.13/org/apache/pekko/stream/javadsl/CollectionUtil.scala similarity index 96% rename from stream/src/main/scala-2.13+/org/apache/pekko/stream/javadsl/CollectionUtil.scala rename to stream/src/main/scala-2.13/org/apache/pekko/stream/javadsl/CollectionUtil.scala index 1a456b5e51..1f83183088 100644 --- a/stream/src/main/scala-2.13+/org/apache/pekko/stream/javadsl/CollectionUtil.scala +++ b/stream/src/main/scala-2.13/org/apache/pekko/stream/javadsl/CollectionUtil.scala @@ -21,6 +21,7 @@ package javadsl import scala.collection.immutable import org.apache.pekko +import pekko.annotation.InternalApi import pekko.util.ccompat.JavaConverters._ /** @@ -28,6 +29,7 @@ import pekko.util.ccompat.JavaConverters._ * * Utility methods for converting Java collections to Scala collections. */ +@InternalApi private[javadsl] object CollectionUtil { @inline def toSeq[T](jlist: java.util.List[T]): immutable.Seq[T] = jlist.asScala.toSeq diff --git a/stream/src/main/scala-3/org/apache/pekko/stream/javadsl/CollectionUtil.scala b/stream/src/main/scala-3/org/apache/pekko/stream/javadsl/CollectionUtil.scala new file mode 100644 index 0000000000..e940c7062d --- /dev/null +++ b/stream/src/main/scala-3/org/apache/pekko/stream/javadsl/CollectionUtil.scala @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pekko.stream +package javadsl + +import scala.collection.immutable + +import org.apache.pekko +import pekko.annotation.InternalApi +import pekko.util.ccompat.JavaConverters._ + +/** + * INTERNAL API + * + * Utility methods for converting Java collections to Scala collections. + */ +@InternalApi +private[javadsl] object CollectionUtil { + inline def toSeq[T](jlist: java.util.List[T]): immutable.Seq[T] = + jlist.asScala.toSeq + + inline def toSeq[T](jiterable: java.lang.Iterable[T]): immutable.Seq[T] = + jiterable.asScala.toSeq +}