@Override public <T> Collection<Resource> getAllocatedResources(Resource parent, Class<T> cls) { checkNotNull(parent); checkNotNull(cls); checkArgument(parent instanceof DiscreteResource); Versioned<Set<Resource>> children = childMap.get((DiscreteResource) parent); if (children == null) { return ImmutableList.of(); } Stream<DiscreteResource> discrete = children .value() .stream() .filter(x -> x.last().getClass().equals(cls)) .filter(x -> x instanceof DiscreteResource) .map(x -> (DiscreteResource) x) .filter(discreteConsumers::containsKey); Stream<ContinuousResource> continuous = children .value() .stream() .filter(x -> x.id().equals(parent.id().child(cls))) .filter(x -> x instanceof ContinuousResource) .map(x -> (ContinuousResource) x) .filter(x -> continuousConsumers.containsKey(x.id())) .filter(x -> continuousConsumers.get(x.id()) != null) .filter(x -> !continuousConsumers.get(x.id()).value().allocations().isEmpty()); return Stream.concat(discrete, continuous).collect(Collectors.toList()); }
@Override public boolean existsTunnelInfo(TunnelId tunnelId) { checkNotNull(tunnelId, TUNNEL_ID_NULL); return tunnelInfoMap.containsKey(tunnelId); }