Skip to content

Commit ee19d7d

Browse files
authored
Case class for BindingCollection/Map (#263)
* Make BindingCollection and BindingMap case class Signed-off-by: Hongxin Liang <[email protected]>
1 parent 489b73a commit ee19d7d

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

flytekit-scala_2.13/src/main/scala/org/flyte/flytekit/BindingCollection.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
package org.flyte.flytekit
1818

1919
import org.flyte.api.v1.BindingData
20-
import org.flyte.flytekit.SdkBindingData.Literal
2120
import org.flyte.flytekitscala.SdkLiteralTypes.collections
2221

2322
import java.util.function
2423
import scala.collection.JavaConverters._
2524

26-
private[flyte] class BindingCollection[T](
25+
private[flyte] case class BindingCollection[T](
2726
elementType: SdkLiteralType[T],
2827
bindingCollection: List[SdkBindingData[T]]
2928
) extends SdkBindingData[List[T]] {

flytekit-scala_2.13/src/main/scala/org/flyte/flytekit/BindingMap.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
package org.flyte.flytekit
1818

1919
import org.flyte.api.v1.BindingData
20-
import org.flyte.flytekit.SdkBindingData.Literal
2120
import org.flyte.flytekitscala.SdkLiteralTypes.maps
2221

2322
import java.util.function
2423
import scala.collection.JavaConverters._
2524

26-
private[flyte] class BindingMap[T](
25+
private[flyte] case class BindingMap[T](
2726
valuesType: SdkLiteralType[T],
2827
bindingMap: Map[String, SdkBindingData[T]]
2928
) extends SdkBindingData[Map[String, T]] {

flytekit-scala_2.13/src/main/scala/org/flyte/flytekit/package.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ package org.flyte
1818

1919
/** Contains subclasses for [[SdkBindingData]]. We are forced to define this
2020
* package here because [[SdkBindingData#idl()]] is package private (we don´t
21-
* want to expose it to users). We cannot make it protected either as it would
22-
* be good for the own object but both implementations deal with list or maps
23-
* of [[SdkBindingData]] and therefore cannot call this method because it is in
24-
* a different class.
21+
* want to expose it to users). Making it protected doesn't help either because
22+
* list or map needs to call this method of elements so that requires it to be
23+
* public.
2524
*
2625
* This is not ideal because we are splitting the flytekit package in two maven
2726
* modules. This would create problems when we decide to add java 9 style

flytekit-scala_2.13/src/main/scala/org/flyte/flytekitscala/SdkBindingDataFactory.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ object SdkBindingDataFactory {
353353
elementType: SdkLiteralType[T],
354354
elements: List[SdkBindingData[T]]
355355
): SdkBindingData[List[T]] = {
356-
new BindingCollection(elementType, elements)
356+
BindingCollection(elementType, elements)
357357
}
358358

359359
/** Creates a [[SdkBindingData]] for a flyte map given a java
@@ -372,7 +372,7 @@ object SdkBindingDataFactory {
372372
valuesType: SdkLiteralType[T],
373373
valueMap: Map[String, SdkBindingData[T]]
374374
): SdkBindingData[Map[String, T]] =
375-
new BindingMap(valuesType, valueMap)
375+
BindingMap(valuesType, valueMap)
376376

377377
private def toSdkLiteralType(
378378
value: Any,

0 commit comments

Comments
 (0)