class ImmutableResources implements Resources {

    public static ImmutableResources of(final Iterable<Resource> resources) {
        checkNotNull(resources, "resources");

        final Map<ResourceKey, Resource> resourcesMap = new HashMap<>();
        resources.forEach(resource -> {
            final Resource existingResource = resourcesMap.put(resource.getResourceKey(), resource);
            if (null != existingResource) {
                final String msgTemplate = "There is more than one Resource with the path <{0}>!";
                throw new IllegalArgumentException(MessageFormat.format(msgTemplate, resource.getPath()));
            }
        });

        return new ImmutableResources(resourcesMap);
    }

    private  ImmutableResources(final Map<ResourceKey, Resource> theResources);

}