class DefaultAvailableResourcesProvider implements AvailableResourcesProvider {

  @Override
  public List<? extends Resource> getAvailableResources(String accountId)
      throws NotFoundException, ServerException {
    ResourceManager resourceManager = resourceManagerProvider.get();
    List<? extends Resource> totalResources = null;
    List<Resource> usedResources = null;
    try {
      totalResources = resourceManager.getTotalResources(accountId);
      usedResources = new ArrayList<>(resourceManager.getUsedResources(accountId));
      return resourceAggregator.deduct(totalResources, usedResources);
    } catch (NoEnoughResourcesException e) {
      LOG.warn(
          "Account with id {} uses more resources {} than he has {}.",
          accountId,
          format(usedResources),
          format(totalResources));
      return resourceAggregator.excess(totalResources, usedResources);
    }
  }

  @Inject public  DefaultAvailableResourcesProvider(
      Provider<ResourceManager> resourceManagerProvider, ResourceAggregator resourceAggregator);

}