1 /*
2  * Hibernate Validator, declare and validate application constraints
3  *
4  * License: Apache License, Version 2.0
5  * See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
6  */

7 package org.hibernate.validator.internal.engine.groups;
8
9 import java.util.Iterator;
10 import java.util.Set;
11
12 import org.hibernate.validator.internal.util.CollectionHelper;
13 import org.hibernate.validator.internal.util.stereotypes.Immutable;
14
15 /**
16  * Represents a validation group and all the groups it extends ("group inheritance").
17  *
18  * @author Gunnar Morling
19  */

20 public class GroupWithInheritance implements Iterable<Group> {
21
22     @Immutable
23     private final Set<Group> groups;
24
25     public GroupWithInheritance(Set<Group> groups) {
26         this.groups = CollectionHelper.toImmutableSet( groups );
27     }
28
29     @Override
30     public Iterator<Group> iterator() {
31         return groups.iterator();
32     }
33 }
34