Skip to content

Commit

Permalink
Case class for BindingCollection/Map (#263)
Browse files Browse the repository at this point in the history
* Make BindingCollection and BindingMap case class

Signed-off-by: Hongxin Liang <honnix@users.noreply.github.com>
  • Loading branch information
honnix authored Oct 19, 2023
1 parent 489b73a commit ee19d7d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
package org.flyte.flytekit

import org.flyte.api.v1.BindingData
import org.flyte.flytekit.SdkBindingData.Literal
import org.flyte.flytekitscala.SdkLiteralTypes.collections

import java.util.function
import scala.collection.JavaConverters._

private[flyte] class BindingCollection[T](
private[flyte] case class BindingCollection[T](
elementType: SdkLiteralType[T],
bindingCollection: List[SdkBindingData[T]]
) extends SdkBindingData[List[T]] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
package org.flyte.flytekit

import org.flyte.api.v1.BindingData
import org.flyte.flytekit.SdkBindingData.Literal
import org.flyte.flytekitscala.SdkLiteralTypes.maps

import java.util.function
import scala.collection.JavaConverters._

private[flyte] class BindingMap[T](
private[flyte] case class BindingMap[T](
valuesType: SdkLiteralType[T],
bindingMap: Map[String, SdkBindingData[T]]
) extends SdkBindingData[Map[String, T]] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ package org.flyte

/** Contains subclasses for [[SdkBindingData]]. We are forced to define this
* package here because [[SdkBindingData#idl()]] is package private (we don´t
* want to expose it to users). We cannot make it protected either as it would
* be good for the own object but both implementations deal with list or maps
* of [[SdkBindingData]] and therefore cannot call this method because it is in
* a different class.
* want to expose it to users). Making it protected doesn't help either because
* list or map needs to call this method of elements so that requires it to be
* public.
*
* This is not ideal because we are splitting the flytekit package in two maven
* modules. This would create problems when we decide to add java 9 style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ object SdkBindingDataFactory {
elementType: SdkLiteralType[T],
elements: List[SdkBindingData[T]]
): SdkBindingData[List[T]] = {
new BindingCollection(elementType, elements)
BindingCollection(elementType, elements)
}

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

private def toSdkLiteralType(
value: Any,
Expand Down

0 comments on commit ee19d7d

Please sign in to comment.