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

org.infinispan.stream.impl.intops.object.MapOperation Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.stream.impl.intops.object;

import org.infinispan.factories.ComponentRegistry;
import org.infinispan.stream.impl.intops.IntermediateOperation;

import java.util.function.Function;
import java.util.stream.Stream;

/**
 * Performs map to operation on a regular {@link Stream}
 * @param  the type of the input stream
 * @param  the type of the output stream
 */
public class MapOperation implements IntermediateOperation, O, Stream> {
   private final Function function;

   public MapOperation(Function function) {
      this.function = function;
   }

   @Override
   public Stream perform(Stream stream) {
      return stream.map(function);
   }

   @Override
   public void handleInjection(ComponentRegistry registry) {
      registry.wireDependencies(function);
   }

   public Function getFunction() {
      return function;
   }
}