code: public GroupChain getGroupChainFor(final Collection<Class<?>> groups) {
      if (groups == null || groups.isEmpty()) {
        throw new IllegalArgumentException("At least one group has to be specified.");
      }
  
      groups.forEach(clazz -> {
        if (!validationGroupsMetadata.containsGroup(clazz)
            && !validationGroupsMetadata.isSeqeuence(clazz)) {
          throw new ValidationException("The class " + clazz + " is not a valid group or sequence.");
        }
      });
  
      final GroupChain chain = new GroupChain();
      groups.forEach(clazz -> {
        if (isGroupSequence(clazz)) {
          insertSequence(clazz, chain);
        } else {
          final Group group = new Group(clazz);
          chain.insertGroup(group);
          insertInheritedGroups(clazz, chain);
        }
      });
  
      return chain;
    }
docs: Generates a chain of groups to be validated given the specified validation groups.
  
  @param groups The groups specified at the validation call.
  
  @return an instance of {@code GroupChain} defining the order in which validation has to occur.