class ContainerManager {

    public <T extends Container> T getMatchingContainer (Class<T> clazz, String uniqueIdentifier) {
        Optional<T> match;
        synchronized (containers) {
            match = containers.stream()
                              .filter(clazz::isInstance)
                              .map(clazz::cast)
                              .filter(container -> container.compareUniqueIdentifier(uniqueIdentifier))
                              .findFirst();
        }
        return match.orElse(null);
    }

}