/*
 * Copyright 2017-present The Material Motion Authors. All Rights Reserved.
 *
 * 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.google.android.material.motion.operators;

import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;

import com.google.android.indefinite.observable.Observer;
import com.google.android.material.motion.Operation;

public class CommonOperators {

  @VisibleForTesting
  public CommonOperators() {
    throw new UnsupportedOperationException();
  }

  public static <T> Operation<T, T> dedupe() {
    return new Operation<T, T>() {

      private boolean dispatched;
      @Nullable
      private T lastValue;

      @Override
      public void next(Observer<T> observer, T value) {
        if (dispatched && lastValue == value) {
          return;
        }

        lastValue = value;
        dispatched = true;

        observer.next(value);
      }
    };
  }
}

@@ -786,16 +786,41 @@
 Testing;
+%0Aimport android.util.Log;
 %0A%0Aimport
@@ -1472,11 +1472,537 @@
   %7D;%0A  %7D
+%0A%0A  public static %3CT%3E Operation%3CT, T%3E log(final String tag) %7B%0A    return log(tag, %22%22);%0A  %7D%0A%0A  public static %3CT%3E Operation%3CT, T%3E log(final String tag, final String prefix) %7B%0A    return log(Log.DEBUG, tag, prefix);%0A  %7D%0A%0A  public static %3CT%3E Operation%3CT, T%3E log(final int priority, final String tag, final String prefix) %7B%0A    return new Operation%3CT, T%3E() %7B%0A      @Override%0A      public void next(Observer%3CT%3E observer, T value) %7B%0A        Log.println(priority, tag, prefix + value);%0A        observer.next(value);%0A      %7D%0A    %7D;%0A  %7D
 %0A%7D%0A

Implement log operator