/**
 * A convenient and memory efficent representation for a list of validators.
 */
static private final class ValidatorList implements IValidator
{
	private final LinkedList list = new LinkedList();

	/**
	 * Constructs a list with validators in it.
	 *
	 * @param left
	 *            The left validator
	 * @param right
	 *            The right validator
	 */
	ValidatorList(final IValidator left, final IValidator right)
	{
		list.add(left);
		list.add(right);
	}

	/**
	 * Gets the string representation of this object.
	 *
	 * @return String representation of this object
	 */
	public String toString()
	{
		return list.toString();
	}

	/**
	 * Validates the given component.
	 *
	 * @param component
	 *            The component to validate
	 */
	public void validate(final FormComponent component)
	{
		for (Iterator i = list.iterator(); i.hasNext();)
		{
			((IValidator) i.next()).validate(component);
		}
	}

	/**
	 * Adds the given code validator to this list of code validators.
	 *
	 * @param validator
	 *            The validator
	 */
	void add(final IValidator validator)
	{
		list.add(validator);
	}

	/**
	 * Gets the validators as a List.
	 *
	 * @return the validators as a List
	 */
	List asList()
	{
		return list;
	}
}