/*
 * Copyright 2011 Raffael Herzog
 *
 * 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 ch.raffael.util.binding.validate;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

import com.sun.xml.internal.stream.util.ReadOnlyIterator;

import ch.raffael.util.binding.PresentationModelMember;


/**
 * @author <a href="mailto:herzog@raffael.ch">Raffael Herzog</a>
 */
public abstract class AbstractCompoundValidator<T> extends PresentationModelMember implements Validator<T>, Iterable<Validator<T>> {

    private final Set<Validator<T>> validators = new LinkedHashSet<Validator<T>>();

    protected AbstractCompoundValidator() {
    }

    protected AbstractCompoundValidator(Validator<T> validator) {
        add(validator);
    }

    protected AbstractCompoundValidator(Collection<Validator<T>> validator) {
        add(validators);
    }

    public AbstractCompoundValidator<T> add(Validator<T> validator) {
        validators.add(validator);
        return this;
    }

    public AbstractCompoundValidator<T> add(Collection<Validator<T>> validators) {
        this.validators.addAll(validators);
        return this;
    }

    @Override
    public Iterator<Validator<T>> iterator() {
        return new ReadOnlyIterator(validators.iterator());
    }
}

@@ -646,47 +646,107 @@
 ort 
-java.util.Collection;%0Aimport java.util.
+ch.raffael.util.binding.PresentationModelMember;%0Aimport ch.raffael.util.common.collections.ReadOnly
 Iter
@@ -751,16 +751,17 @@
 erator;%0A
+%0A
 import j
@@ -769,29 +769,26 @@
 va.util.
-LinkedHashSet
+Collection
 ;%0Aimport
@@ -802,127 +802,70 @@
 til.
-Set
+Iterator
 ;%0A
-%0A
 import 
-com.sun.xml.internal.stream.util.ReadOnlyIterator;%0A%0Aimport ch.raffael.util.binding.PresentationModelMember
+java.util.LinkedHashSet;%0Aimport java.util.Set
 ;%0A%0A%0A
@@ -1798,16 +1798,30 @@
 Iterator
+%3CValidator%3CT%3E%3E
 (validat

remove com.sun.* import. instead use ch.r.u.c.c.ReadOnlyIterator