SharedRiskGroup extends NetworkElement { public boolean affectsAnyOf (Collection<? extends NetworkElement> col) { final SortedSet<Node> nodesThisSrg = getNodes (); for (NetworkElement e : col) { if (e instanceof Link) { final Link ee = (Link) e; if (nodesThisSrg.contains(ee.originNode)) return true; if (nodesThisSrg.contains(ee.destinationNode)) return true; if (getLinksAllLayers().contains(ee)) return true; } else if (e instanceof Resource) { final Resource ee = (Resource) e; if (ee.hostNode.isPresent()) if (nodesThisSrg.contains(ee.hostNode.get())) return true; } else if (e instanceof Node) { final Node ee = (Node) e; if (nodesThisSrg.contains(ee)) return true; } else throw new Net2PlanException ("The collection can contain only links, resources and/or nodes"); } return false; } SharedRiskGroup(NetPlan netPlan , long id , int index , SortedSet<Node> nodes , SortedSet<Link> links , double meanTimeToFailInHours ,  double meanTimeToRepairInHours , AttributeMap attributes);   SharedRiskGroup(NetPlan netPlan , long id , int index , String className , String dynamicInitializationString , double meanTimeToFailInHours ,  double meanTimeToRepairInHours , AttributeMap attributes); boolean isDynamicSrg(); DynamicSrgImplementation getDynamicSrgImplementation(); void setDynamicImplementation(DynamicSrgImplementation impl); boolean isStaticEmptySrg(); boolean isDynamicCurrentlyEmptySrg(); static SharedRiskGroup getDummyEmptyStaticSrg(NetPlan np); static SortedSet<SharedRiskGroup> getSrgListCompletedWithDummyNoFailureStateIfNeeded(Collection<SharedRiskGroup> sourceSrgs , NetPlan np); SortedSet<Node> getNodes(); SortedSet<Link> getAffectedLinksAllLayers(); SortedSet<Link> getAffectedLinks(NetworkLayer layer); SortedSet<Route> getAffectedRoutesAllLayers(); SortedSet<Route> getAffectedRoutes(NetworkLayer layer); SortedSet<MulticastTree> getAffectedMulticastTreesAllLayers(); SortedSet<MulticastTree> getAffectedMulticastTrees(NetworkLayer layer); boolean affectsAnyOf(Collection<? extends NetworkElement> col); SortedSet<Link> getLinksAllLayers(); SortedSet<Link> getLinks(NetworkLayer layer); double getMeanTimeToFailInHours(); void setMeanTimeToFailInHours(double value); double getMeanTimeToRepairInHours(); void setMeanTimeToRepairInHours(double value); double getAvailability(); void setAsDown(); void setAsUp(); void removeLink(Link e); void removeNode(Node n); void remove(); void addLink(Link link); void addNode(Node node); String toString();  }
@Test public void testAffectsAnyOf() { assertEquals(srgL13.affectsAnyOf(Arrays.asList(n1,link23)) , false); assertEquals(srgN1L23.affectsAnyOf(Arrays.asList(n2,link23)) , true); assertEquals(srgN1L23.affectsAnyOf(Arrays.asList(n2,link13)) , true); assertEquals(srgN1L23.affectsAnyOf(Arrays.asList(n2)) , false); }