class ResourceAggregator {

  public Map<String, Resource> aggregateByType(List<? extends Resource> resources) {
    checkSupporting(resources);

    Map<String, Resource> type2Resource = new HashMap<>();
    for (Resource resource : resources) {
      final Resource resource1 = type2Resource.get(resource.getType());
      if (resource1 != null) {
        type2Resource.put(resource.getType(), aggregate(resource1, resource));
      } else {
        type2Resource.put(resource.getType(), resource);
      }
    }
    return type2Resource;
  }

  @Inject public  ResourceAggregator(Set<ResourceType> resourcesTypes);

}