/*-
 * -\-\-
 * Flo Workflow Definition
 * --
 * Copyright (C) 2016 - 2017 Spotify AB
 * --
 * 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 com.spotify.flo;

import static com.spotify.flo.BuilderUtils.guardedCall;

import java.io.Serializable;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * An operator controls the execution of a job for a task,  e.g. a data processing job on some processing platform.
 *
 * <p>The concrete operator implementation should {@link #provide(EvalContext)} the task with some means of constructing
 * an operation description. The operation description should be returned from the process fn.
 */
public interface TaskOperator<ContextT, SpecT, ResultT>
    extends TaskContext<ContextT> {

  ResultT perform(SpecT spec, Listener listener);

  interface Listener extends Serializable {

    /**
     * Called to report some piece of task metadata.
     *
     * By default this methods calls {@link #meta(TaskId, Map)} with a single entry.
     *
     * @param task The task that is being evaluated
     * @param key The metadata key.
     * @param value The metadata value.
     */
    default void meta(TaskId task, String key, String value) {
      meta(task, Collections.singletonMap(key, value));
    }

    /**
     * Called to report some piece of task metadata.
     *
     * @param task The task that is being evaluated
     * @param data The key-value metadata
     */
    void meta(TaskId task, Map<String, String> data);

    Listener NOP = (task, data) -> { };

    default Listener composeWith(Listener listener) {
      return (task, data) -> {
        guardedCall(() -> Listener.this.meta(task, data));
        guardedCall(() -> listener.meta(task, data));
      };
    }
  }
}

@@ -790,88 +790,11 @@
 til.
-Collections;%0Aimport java.util.Map;%0Aimport java.util.concurrent.CompletableFuture
+Map
 ;%0A%0A/
@@ -1279,16 +1279,39 @@
 ener);%0A%0A
+  @FunctionalInterface%0A
   interf
@@ -1351,430 +1351,8 @@
  %7B%0A%0A
-    /**%0A     * Called to report some piece of task metadata.%0A     *%0A     * By default this methods calls %7B@link #meta(TaskId, Map)%7D with a single entry.%0A     *%0A     * @param task The task that is being evaluated%0A     * @param key The metadata key.%0A     * @param value The metadata value.%0A     */%0A    default void meta(TaskId task, String key, String value) %7B%0A      meta(task, Collections.singletonMap(key, value));%0A    %7D%0A%0A
     

remove single-entry meta method