class WorkspaceResourceUsageTracker implements ResourceUsageTracker {

  @Override
  public Optional<Resource> getUsedResource(String accountId)
      throws NotFoundException, ServerException {
    final Account account = accountManager.getById(accountId);
    final List<WorkspaceImpl> accountWorkspaces =
        Pages.stream(
                (maxItems, skipCount) ->
                    workspaceManagerProvider
                        .get()
                        .getByNamespace(account.getName(), false, maxItems, skipCount))
            .collect(Collectors.toList());
    if (!accountWorkspaces.isEmpty()) {
      return Optional.of(
          new ResourceImpl(
              WorkspaceResourceType.ID, accountWorkspaces.size(), WorkspaceResourceType.UNIT));
    } else {
      return Optional.empty();
    }
  }

  @Inject public  WorkspaceResourceUsageTracker(
      Provider<WorkspaceManager> workspaceManagerProvider, AccountManager accountManager);

}