/*
 * 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.github.bckfnn.reactstreams.ops;

import java.io.PrintStream;

import com.github.bckfnn.reactstreams.BaseProcessor;

public class PrintStreamOp<T> extends BaseProcessor<T, T> {
	private String prefix;
	private PrintStream printStream;
	
	public PrintStreamOp(String prefix, PrintStream printStream) {
		this.prefix = prefix;
		this.printStream = printStream;
	}
	
	@Override
	public void doNext(T value) {
		printStream.println(prefix + " onNext:" + value);
		sendNext(value);
	}
	
	@Override
	public void onError(Throwable error) {
		printStream.println(prefix + " onError:" + error);
		super.onError(error);
	}

	@Override
	public void onComplete() {
		printStream.println(prefix + " onComplete");
		super.onComplete();
	}



}

@@ -638,24 +638,68 @@
 tStream;%0D%0A%0D%0A
+import org.reactivestreams.Subscription;%0D%0A%0D%0A
 import com.g
@@ -991,25 +991,159 @@
 tream;%0D%0A%09%7D%0D%0A
-%09
+%0D%0A%09public void onSubscribe(Subscription s) %7B%0D%0A%09    printStream.println(prefix + %22 onSubScribe:%22 + s);%0D%0A%09    super.onSubscribe(s);%0D%0A%09%7D%0D%0A
 %0D%0A%09@Override
@@ -1512,15 +1512,302 @@
 %0D%0A%09%7D%0D%0A%0D%0A
-%0D%0A
+    @Override%0D%0A    public void sendCancel() %7B%0D%0A        printStream.println(prefix + %22 cancel%22);%0D%0A        super.sendCancel();%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    protected void sendRequest(int n) %7B%0D%0A        printStream.println(prefix + %22 request(%22 + n + %22)%22);%0D%0A        super.sendRequest(n);%0D%0A    %7D
 %0D%0A%7D%0D%0A

print onSubscribe, request and cancel.