All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.flyte.flytekit.BindingCollection.scala Maven / Gradle / Ivy

Go to download

Classes used by developers to build Flyte's Tasks, Workflows and Launch plans in Scala 2.12.

The newest version!
/*
 * Copyright 2020-2023 Flyte Authors.
 *
 * Licensed 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.flyte.flytekit

import org.flyte.api.v1.BindingData
import org.flyte.flytekitscala.SdkLiteralTypes.collections

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

private[flyte] case class BindingCollection[T](
    elementType: SdkLiteralType[T],
    bindingCollection: List[SdkBindingData[T]]
) extends SdkBindingData[List[T]] {
  SdkBindingData.checkIncompatibleTypes(elementType, bindingCollection.asJava)

  override def idl: BindingData =
    BindingData.ofCollection(bindingCollection.map(_.idl()).asJava)

  override def `type`: SdkLiteralType[List[T]] = collections(elementType)

  override def get(): List[T] = bindingCollection.map(_.get())

  override def as[NewT](
      newType: SdkLiteralType[NewT],
      castFunction: function.Function[List[T], NewT]
  ): SdkBindingData[NewT] =
    SdkBindingData.literal(newType, castFunction.apply(get()))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy