class ResourceAggregator {

  public List<? extends Resource> min(Collection<? extends Resource> resources) {
    checkSupporting(resources);
    Map<String, Resource> result = new HashMap<>();
    for (Resource resource : resources) {
      String type = resource.getType();
      Resource min = result.get(type);
      if (min == null) {
        result.put(type, resource);
      } else if (resource.getAmount() != -1) {
        if (min.getAmount() == -1 || min.getAmount() > resource.getAmount()) {
          result.put(type, resource);
        }
      }
    }
    return new ArrayList<>(result.values());
  }

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

}