class ImmutableSubjects implements Subjects {

    public static ImmutableSubjects of(final Iterable<Subject> subjects) {
        checkNotNull(subjects, "subjects");

        final Map<SubjectId, Subject> subjectsMap = new HashMap<>();
        subjects.forEach(subject -> {
            final Subject existingSubject = subjectsMap.put(subject.getId(), subject);
            if (null != existingSubject) {
                final String msgTemplate = "There is more than one Subject with the ID <{0}>!";
                throw new IllegalArgumentException(MessageFormat.format(msgTemplate, subject.getId()));
            }
        });

        return new ImmutableSubjects(subjectsMap);
    }

    private  ImmutableSubjects(final Map<SubjectId, Subject> theSubjects);

}