/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * license agreements; and to You under the Apache License, version 2.0:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * This file is part of the Apache Pekko project, which was derived from Akka.
 */

/*
 * Copyright (C) 2014-2022 Lightbend Inc. <https://www.lightbend.com>
 */

package org.apache.pekko.stream.javadsl

import org.apache.pekko.stream._
import org.apache.pekko.stream.scaladsl
import org.apache.pekko.japi.function
import org.apache.pekko.NotUsed

/**
 * Combine the elements of multiple streams into a stream of combined elements using a combiner function.
 *
 * '''Emits when''' all of the inputs has an element available
 *
 * '''Backpressures when''' downstream backpressures
 *
 * '''Completes when''' any upstream completes
 *
 * '''Cancels when''' downstream cancels
 */
object ZipWith {

  /**
   * Create a new `ZipWith` vertex with the specified input types and zipping-function `f`.
   *
   * @param f zipping-function from the input values to the output value
   * @param attributes optional attributes for this vertex
   */
  def create[A, B, Out](f: function.Function2[A, B, Out]): Graph[FanInShape2[A, B, Out], NotUsed] =
    scaladsl.ZipWith(f.apply _)

  [3..22#/** Create a new `ZipWith` specialized for 1 inputs.
   *
   * @param f zipping-function from the input values to the output value
   * @param attributes optional attributes for this vertex
   */
  def create1[[#T1#], Out](f: function.Function1[[#T1#], Out]): Graph[FanInShape1[[#T1#], Out], NotUsed] =
    scaladsl.ZipWith(f.apply _)#
    
  ]

}
