package com.jkoolcloud.tnt4j.streams.outputs;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;

import org.apache.commons.collections4.CollectionUtils;

import com.jkoolcloud.tnt4j.sink.EventSink;
import com.jkoolcloud.tnt4j.streams.inputs.TNTInputStream;

public abstract class AbstractTNTStreamOutput<T> implements TNTStreamOutput<T> {

	private String name;
	private TNTInputStream<?, ?> stream;

	private boolean closed = false;

	protected AbstractTNTStreamOutput() {
	}

	protected AbstractTNTStreamOutput(String name) {
		this.name = name;
	}

	/**
	 * Returns logger used by this stream output handler.
	 *
	 * @return parser logger
	 */
	protected abstract EventSink logger();

	@Override
	public void setStream(TNTInputStream<?, ?> inputStream) {
		this.stream = inputStream;
	}

	@Override
	public TNTInputStream<?, ?> getStream() {
		return stream;
	}

	/**
	 * Returns output name value.
	 *
	 * @return output name value
	 */
	@Override
	public String getName() {
		return name;
	}

	/**
	 * Sets output name value.
	 *
	 * @param name
	 *            output name value
	 */
	@Override
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public void setProperties(Collection<Map.Entry<String, String>> props) {
		if (CollectionUtils.isNotEmpty(props)) {
			for (Map.Entry<String, String> prop : props) {
				setProperty(prop.getKey(), prop.getValue());
			}
		}
	}

	@Override
	public boolean isClosed() {
		return closed;
	}

	protected void setClosed(boolean closed) {
		this.closed = closed;
	}

	@Override
	public void cleanup() {
		closed = true;

	}

	@Override
	public void logItem(T item) throws Exception {
		notifyLogItem(item);
	}

	/**
	 * Returns empty statistics map.
	 *
	 * @return empty map
	 */
	@Override
	public Map<String, Object> getStats() {
		return Collections.emptyMap();
	}
}

@@ -46,37 +46,8 @@
 %0D%0A%0D%0A
-import java.util.ArrayList;%0D%0A
 impo
@@ -1707,99 +1707,8 @@
 %0D%0A%0D%0A
-%09@Override%0D%0A%09public void logItem(T item) throws Exception %7B%0D%0A%09%09notifyLogItem(item);%0D%0A%09%7D%0D%0A%0D%0A
 %09/**

build fix.