package org.pmdreports.util;

import java.util.List;

import org.apache.log4j.Logger;

/**
 * A set of static utility methods for List processing.
 * 
 * @author Ben Northrop Sep 25, 2007
 */
public final class ListUtil {

	private final static Logger LOG = Logger.getLogger(ListUtil.class);

	/**
	 * Private constructor for utilities class.
	 */
	private ListUtil() {
		// do nothing
	}

	/**
	 * Helper method to get an integer from the list, given the index.
	 */
	public static int getValue(List list, int index) {
		try {
			return Integer.parseInt(list.get(index).toString());
		} catch (NumberFormatException nfe) {
			LOG.warn("NumberFormatException for index: " + index
					+ " and list: " + list);
			return -1;
		}
	}
}
