class ResourceAggregator {

  public List<? extends Resource> intersection(
      List<? extends Resource> resourcesA, List<? extends Resource> resourcesB) {
    checkSupporting(resourcesA);
    checkSupporting(resourcesB);

    final Set<String> keysA = resourcesA.stream().map(Resource::getType).collect(toSet());
    final Set<String> keysB = resourcesB.stream().map(Resource::getType).collect(toSet());
    final Set<String> commonKeys = ImmutableSet.copyOf(Sets.intersection(keysA, keysB));
    return Stream.concat(resourcesA.stream(), resourcesB.stream())
        .filter(res -> commonKeys.contains(res.getType()))
        .collect(Collectors.toList());
  }

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

}