/*
 * Lingua::StanfordCoreNLP
 * Copyright © 2011-2013 Kalle Räisänen.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see L<http://www.gnu.org/licenses/>.
 */
package be.fivebyfive.lingua.stanfordcorenlp;

import java.util.ArrayList;
import java.util.HashMap;

public class PipelineList<T> extends ArrayList<T> {
	public String joinList(String sep) {
		String output = "";
		for(T elem: this) {
			output += (output.length() > 0 ? sep : "") + elem.toString();
		}
		return output;
	}

	public String joinListCompact(String sep) {
		String output = "";
		for(T elem: this) {
			output += (output.length() > 0 ? sep : "") + ((PipelineItem)elem).toCompactString();
		}
		return output;
	}

	public HashMap<String,T> toHashMap() {
		HashMap<String,T> hm = new HashMap<String,T>();

		for(T elem: this) {
			hm.put( ((PipelineItem)elem).getIDString(), elem);
		}

		return hm;
	}

	public String toCompactString()    { return joinListCompact("\n"); }
	@Override public String toString() { return joinList("\n"); }
}
